diff options
author | Mike Aizatsky <aizatsky@chromium.org> | 2016-03-21 23:08:16 +0000 |
---|---|---|
committer | Mike Aizatsky <aizatsky@chromium.org> | 2016-03-21 23:08:16 +0000 |
commit | 602f79275dcb5a65a0bd0e5917763b4f5b1eb904 (patch) | |
tree | e2a5e3c751042cc51dfb1ea9dc29425e2002132c | |
parent | 32835c82d5e7756c4aa601c84a4965bbe7d0399d (diff) | |
download | bcm5719-llvm-602f79275dcb5a65a0bd0e5917763b4f5b1eb904.tar.gz bcm5719-llvm-602f79275dcb5a65a0bd0e5917763b4f5b1eb904.zip |
[sancov] do not instrument nodes that are full pre-dominators
Summary:
Without tree pruning clang has 2,667,552 points.
Wiht only dominators pruning: 1,515,586.
With both dominators & predominators pruning: 1,340,534.
Resubmit of r262103.
Differential Revision: http://reviews.llvm.org/D18341
llvm-svn: 264003
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp index ac7859132ff..9f008977882 100644 --- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -315,20 +315,24 @@ bool SanitizerCoverageModule::runOnModule(Module &M) { return true; } -static bool shouldInstrumentBlock(const BasicBlock *BB, - const DominatorTree *DT) { +static bool shouldInstrumentBlock(const BasicBlock *BB, const DominatorTree *DT, + const PostDominatorTree *PDT) { if (!ClPruneBlocks) return true; - if (succ_begin(BB) == succ_end(BB)) - return true; // Check if BB dominates all its successors. + bool DominatesAll = succ_begin(BB) != succ_end(BB); for (const BasicBlock *SUCC : make_range(succ_begin(BB), succ_end(BB))) { - if (!DT->dominates(BB, SUCC)) - return true; + DominatesAll &= DT->dominates(BB, SUCC); + } + + // Check if BB pre-dominates all predecessors. + bool PreDominatesAll = pred_begin(BB) != pred_end(BB); + for (const BasicBlock *PRED : make_range(pred_begin(BB), pred_end(BB))) { + PreDominatesAll &= PDT->dominates(BB, PRED); } - return false; + return !(DominatesAll || PreDominatesAll); } bool SanitizerCoverageModule::runOnFunction(Function &F) { @@ -349,10 +353,13 @@ bool SanitizerCoverageModule::runOnFunction(Function &F) { SmallVector<Instruction *, 8> CmpTraceTargets; SmallVector<Instruction *, 8> SwitchTraceTargets; - DominatorTree DT; - DT.recalculate(F); + const DominatorTree *DT = + &getAnalysis<DominatorTreeWrapperPass>(F).getDomTree(); + const PostDominatorTree *PDT = + &getAnalysis<PostDominatorTreeWrapperPass>(F).getPostDomTree(); + for (auto &BB : F) { - if (shouldInstrumentBlock(&BB, &DT)) + if (shouldInstrumentBlock(&BB, DT, PDT)) BlocksToInstrument.push_back(&BB); for (auto &Inst : BB) { if (Options.IndirectCalls) { |