mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-13 14:46:53 +00:00
[sancov] code readability improvement.
Summary: Reply to http://reviews.llvm.org/D18341 Differential Revision: http://reviews.llvm.org/D18406 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264213 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8b620f3783
commit
bbc99ea0f8
@ -315,24 +315,39 @@ bool SanitizerCoverageModule::runOnModule(Module &M) {
|
||||
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;
|
||||
|
||||
for (const BasicBlock *SUCC : make_range(succ_begin(BB), succ_end(BB))) {
|
||||
if (!DT->dominates(BB, SUCC))
|
||||
return false;
|
||||
}
|
||||
|
||||
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 BasicBlock *BB, const DominatorTree *DT,
|
||||
const PostDominatorTree *PDT) {
|
||||
if (!ClPruneBlocks)
|
||||
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))) {
|
||||
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 !(DominatesAll || PreDominatesAll);
|
||||
return !(isFullDominator(BB, DT) || isFullPostDominator(BB, PDT));
|
||||
}
|
||||
|
||||
bool SanitizerCoverageModule::runOnFunction(Function &F) {
|
||||
|
Loading…
Reference in New Issue
Block a user