llvm.org GIT mirror llvm / 1ec923a
[sancov] save entry block from pruning (it is always full dominator) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265168 91177308-0d34-0410-b5e6-96231b3b80d8 Mike Aizatsky 4 years ago
2 changed file(s) with 5 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
341341 return true;
342342 }
343343
344 static bool shouldInstrumentBlock(const BasicBlock *BB, const DominatorTree *DT,
344 static bool shouldInstrumentBlock(const Function& F, const BasicBlock *BB, const DominatorTree *DT,
345345 const PostDominatorTree *PDT) {
346 if (!ClPruneBlocks)
346 if (!ClPruneBlocks || &F.getEntryBlock() == BB)
347347 return true;
348348
349349 return !(isFullDominator(BB, DT) || isFullPostDominator(BB, PDT));
373373 &getAnalysis(F).getPostDomTree();
374374
375375 for (auto &BB : F) {
376 if (shouldInstrumentBlock(&BB, DT, PDT))
376 if (shouldInstrumentBlock(F, &BB, DT, PDT))
377377 BlocksToInstrument.push_back(&BB);
378378 for (auto &Inst : BB) {
379379 if (Options.IndirectCalls) {
1212 ; RUN: -S | FileCheck %s --check-prefix=CHECK2
1313 ; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -sanitizer-coverage-block-threshold=1 \
1414 ; RUN: -S | FileCheck %s --check-prefix=CHECK_WITH_CHECK
15 ; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -sanitizer-coverage-prune-blocks=1 -S | FileCheck %s --check-prefix=CHECKPRUNE
15 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-prune-blocks=1 -S | FileCheck %s --check-prefix=CHECKPRUNE
1616
1717 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
1818 target triple = "x86_64-unknown-linux-gnu"
137137
138138 ; CHECKPRUNE-LABEL: define void @foo
139139 ; CHECKPRUNE: call void @__sanitizer_cov
140 ; CHECKPRUNE: call void asm sideeffect "", ""()
141140 ; CHECKPRUNE: call void @__sanitizer_cov
142 ; CHECKPRUNE: call void asm sideeffect "", ""()
141 ; CHECKPRUNE: call void @__sanitizer_cov
143142 ; CHECKPRUNE-NOT: call void @__sanitizer_cov
144143 ; CHECKPRUNE: ret void