@@ -204,12 +204,11 @@ SanitizerCoverageOptions OverrideFromCL(SanitizerCoverageOptions Options) {
204
204
return Options;
205
205
}
206
206
207
- using DomTreeCallback = function_ref<const DominatorTree *(Function &F)>;
208
- using PostDomTreeCallback =
209
- function_ref<const PostDominatorTree *(Function &F)>;
210
-
211
207
class ModuleSanitizerCoverage {
212
208
public:
209
+ using DomTreeCallback = function_ref<const DominatorTree &(Function &F)>;
210
+ using PostDomTreeCallback =
211
+ function_ref<const PostDominatorTree &(Function &F)>;
213
212
ModuleSanitizerCoverage (
214
213
const SanitizerCoverageOptions &Options = SanitizerCoverageOptions(),
215
214
const SpecialCaseList *Allowlist = nullptr ,
@@ -289,11 +288,11 @@ PreservedAnalyses SanitizerCoveragePass::run(Module &M,
289
288
ModuleSanitizerCoverage ModuleSancov (Options, Allowlist.get (),
290
289
Blocklist.get ());
291
290
auto &FAM = MAM.getResult <FunctionAnalysisManagerModuleProxy>(M).getManager ();
292
- auto DTCallback = [&FAM](Function &F) -> const DominatorTree * {
293
- return & FAM.getResult <DominatorTreeAnalysis>(F);
291
+ auto DTCallback = [&FAM](Function &F) -> const DominatorTree & {
292
+ return FAM.getResult <DominatorTreeAnalysis>(F);
294
293
};
295
- auto PDTCallback = [&FAM](Function &F) -> const PostDominatorTree * {
296
- return & FAM.getResult <PostDominatorTreeAnalysis>(F);
294
+ auto PDTCallback = [&FAM](Function &F) -> const PostDominatorTree & {
295
+ return FAM.getResult <PostDominatorTreeAnalysis>(F);
297
296
};
298
297
if (!ModuleSancov.instrumentModule (M, DTCallback, PDTCallback))
299
298
return PreservedAnalyses::all ();
@@ -519,29 +518,29 @@ bool ModuleSanitizerCoverage::instrumentModule(
519
518
}
520
519
521
520
// True if block has successors and it dominates all of them.
522
- static bool isFullDominator (const BasicBlock *BB, const DominatorTree * DT) {
521
+ static bool isFullDominator (const BasicBlock *BB, const DominatorTree & DT) {
523
522
if (succ_empty (BB))
524
523
return false ;
525
524
526
525
return llvm::all_of (successors (BB), [&](const BasicBlock *SUCC) {
527
- return DT-> dominates (BB, SUCC);
526
+ return DT. dominates (BB, SUCC);
528
527
});
529
528
}
530
529
531
530
// True if block has predecessors and it postdominates all of them.
532
531
static bool isFullPostDominator (const BasicBlock *BB,
533
- const PostDominatorTree * PDT) {
532
+ const PostDominatorTree & PDT) {
534
533
if (pred_empty (BB))
535
534
return false ;
536
535
537
536
return llvm::all_of (predecessors (BB), [&](const BasicBlock *PRED) {
538
- return PDT-> dominates (BB, PRED);
537
+ return PDT. dominates (BB, PRED);
539
538
});
540
539
}
541
540
542
541
static bool shouldInstrumentBlock (const Function &F, const BasicBlock *BB,
543
- const DominatorTree * DT,
544
- const PostDominatorTree * PDT,
542
+ const DominatorTree & DT,
543
+ const PostDominatorTree & PDT,
545
544
const SanitizerCoverageOptions &Options) {
546
545
// Don't insert coverage for blocks containing nothing but unreachable: we
547
546
// will never call __sanitizer_cov() for them, so counting them in
@@ -569,17 +568,16 @@ static bool shouldInstrumentBlock(const Function &F, const BasicBlock *BB,
569
568
&& !(isFullPostDominator (BB, PDT) && !BB->getSinglePredecessor ());
570
569
}
571
570
572
-
573
571
// Returns true iff From->To is a backedge.
574
572
// A twist here is that we treat From->To as a backedge if
575
573
// * To dominates From or
576
574
// * To->UniqueSuccessor dominates From
577
575
static bool IsBackEdge (BasicBlock *From, BasicBlock *To,
578
- const DominatorTree * DT) {
579
- if (DT-> dominates (To, From))
576
+ const DominatorTree & DT) {
577
+ if (DT. dominates (To, From))
580
578
return true ;
581
579
if (auto Next = To->getUniqueSuccessor ())
582
- if (DT-> dominates (Next, From))
580
+ if (DT. dominates (Next, From))
583
581
return true ;
584
582
return false ;
585
583
}
@@ -589,7 +587,7 @@ static bool IsBackEdge(BasicBlock *From, BasicBlock *To,
589
587
//
590
588
// Note that Cmp pruning is controlled by the same flag as the
591
589
// BB pruning.
592
- static bool IsInterestingCmp (ICmpInst *CMP, const DominatorTree * DT,
590
+ static bool IsInterestingCmp (ICmpInst *CMP, const DominatorTree & DT,
593
591
const SanitizerCoverageOptions &Options) {
594
592
if (!Options.NoPrune )
595
593
if (CMP->hasOneUse ())
@@ -641,8 +639,8 @@ void ModuleSanitizerCoverage::instrumentFunction(
641
639
SmallVector<LoadInst *, 8 > Loads;
642
640
SmallVector<StoreInst *, 8 > Stores;
643
641
644
- const DominatorTree * DT = DTCallback (F);
645
- const PostDominatorTree * PDT = PDTCallback (F);
642
+ const DominatorTree & DT = DTCallback (F);
643
+ const PostDominatorTree & PDT = PDTCallback (F);
646
644
bool IsLeafFunc = true ;
647
645
648
646
for (auto &BB : F) {
0 commit comments