diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2017-05-23 21:58:54 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2017-05-23 21:58:54 +0000 |
commit | 9017ca290aba42802a42b5d5eb4e04b754518df9 (patch) | |
tree | f38db0568802808cf7104a42822e7687e6b74cab /llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp | |
parent | 8c605c0edaa909f44e6e4c753eb630035de61857 (diff) | |
download | bcm5719-llvm-9017ca290aba42802a42b5d5eb4e04b754518df9.tar.gz bcm5719-llvm-9017ca290aba42802a42b5d5eb4e04b754518df9.zip |
Disable coverage opt-out for strong postdominator blocks.
Coverage instrumentation has an optimization not to instrument extra
blocks, if the pass is already "accounted for" by a
successor/predecessor basic block.
However (https://github.com/google/sanitizers/issues/783) this
reasoning may become circular, which stops valid paths from having
coverage.
In the worst case this can cause fuzzing to stop working entirely.
This change simplifies logic to something which trivially can not have
such circular reasoning, as losing valid paths does not seem like a
good trade-off for a ~15% decrease in the # of instrumented basic blocks.
llvm-svn: 303698
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp index 4bc0a713311..2329cbf4d6b 100644 --- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -31,7 +31,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Analysis/EHPersonalities.h" -#include "llvm/Analysis/PostDominators.h" #include "llvm/IR/CFG.h" #include "llvm/IR/CallSite.h" #include "llvm/IR/DataLayout.h" @@ -169,7 +168,6 @@ public: void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<DominatorTreeWrapperPass>(); - AU.addRequired<PostDominatorTreeWrapperPass>(); } private: @@ -367,23 +365,8 @@ static bool isFullDominator(const BasicBlock *BB, const DominatorTree *DT) { return true; } -// True if block has predecessors and it postdominates all of them. -static bool isFullPostDominator(const BasicBlock *BB, - const PostDominatorTree *PDT) { - if (pred_begin(BB) == pred_end(BB)) - return false; - - for (const BasicBlock *PRED : make_range(pred_begin(BB), pred_end(BB))) { - if (!PDT->dominates(BB, PRED)) - return false; - } - - return true; -} - static bool shouldInstrumentBlock(const Function &F, const BasicBlock *BB, const DominatorTree *DT, - const PostDominatorTree *PDT, const SanitizerCoverageOptions &Options) { // Don't insert coverage for unreachable blocks: we will never call // __sanitizer_cov() for them, so counting them in @@ -401,7 +384,7 @@ static bool shouldInstrumentBlock(const Function &F, const BasicBlock *BB, if (Options.NoPrune || &F.getEntryBlock() == BB) return true; - return !(isFullDominator(BB, DT) || isFullPostDominator(BB, PDT)); + return !isFullDominator(BB, DT); } bool SanitizerCoverageModule::runOnFunction(Function &F) { @@ -433,11 +416,9 @@ bool SanitizerCoverageModule::runOnFunction(Function &F) { const DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>(F).getDomTree(); - const PostDominatorTree *PDT = - &getAnalysis<PostDominatorTreeWrapperPass>(F).getPostDomTree(); for (auto &BB : F) { - if (shouldInstrumentBlock(F, &BB, DT, PDT, Options)) + if (shouldInstrumentBlock(F, &BB, DT, Options)) BlocksToInstrument.push_back(&BB); for (auto &Inst : BB) { if (Options.IndirectCalls) { @@ -719,7 +700,6 @@ INITIALIZE_PASS_BEGIN(SanitizerCoverageModule, "sancov", "ModulePass", false, false) INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) -INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass) INITIALIZE_PASS_END(SanitizerCoverageModule, "sancov", "SanitizerCoverage: TODO." "ModulePass", |