diff options
author | Mike Aizatsky <aizatsky@chromium.org> | 2016-03-23 23:15:03 +0000 |
---|---|---|
committer | Mike Aizatsky <aizatsky@chromium.org> | 2016-03-23 23:15:03 +0000 |
commit | 9987f43ffa3e422efb0bc83186f5066f0155bf4c (patch) | |
tree | 067164f63745c5bd6df448fca9e56d65a6f9dbcf /llvm/lib/Transforms/Instrumentation | |
parent | 0f432aa05a4c32ab818f2e4cfc5ad2a5a8093c56 (diff) | |
download | bcm5719-llvm-9987f43ffa3e422efb0bc83186f5066f0155bf4c.tar.gz bcm5719-llvm-9987f43ffa3e422efb0bc83186f5066f0155bf4c.zip |
[sancov] code readability improvement.
Summary: Reply to http://reviews.llvm.org/D18341
Differential Revision: http://reviews.llvm.org/D18406
llvm-svn: 264213
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp index 9f008977882..12fdfbde18f 100644 --- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -315,24 +315,39 @@ bool SanitizerCoverageModule::runOnModule(Module &M) { return true; } -static bool shouldInstrumentBlock(const BasicBlock *BB, const DominatorTree *DT, - const PostDominatorTree *PDT) { - if (!ClPruneBlocks) - return true; +// True if block has successors and it dominates all of them. +static bool isFullDominator(const BasicBlock *BB, const DominatorTree *DT) { + if (succ_begin(BB) == succ_end(BB)) + return false; - // 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))) { - DominatesAll &= DT->dominates(BB, SUCC); + if (!DT->dominates(BB, SUCC)) + return false; } - // Check if BB pre-dominates all predecessors. - bool PreDominatesAll = pred_begin(BB) != pred_end(BB); + 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))) { - PreDominatesAll &= PDT->dominates(BB, PRED); + if (!PDT->dominates(BB, PRED)) + return false; } - return !(DominatesAll || PreDominatesAll); + return true; +} + +static bool shouldInstrumentBlock(const BasicBlock *BB, const DominatorTree *DT, + const PostDominatorTree *PDT) { + if (!ClPruneBlocks) + return true; + + return !(isFullDominator(BB, DT) || isFullPostDominator(BB, PDT)); } bool SanitizerCoverageModule::runOnFunction(Function &F) { |