improve join-order for Configuration::barrierGuardBlocksEdge

This commit is contained in:
Erik Krogh Kristensen
2021-02-18 16:32:38 +01:00
parent f81860c402
commit 814b5577f5

View File

@@ -474,20 +474,29 @@ pragma[nomagic]
private predicate barrierGuardBlocksEdge(
BarrierGuardNode guard, DataFlow::Node pred, DataFlow::Node succ, string label
) {
barrierGuardIsRelevant(guard) and
exists(
SsaVariable input, SsaPhiNode phi, BasicBlock bb, ConditionGuardNode cond, boolean outcome
|
bb = getADominatedBasicBlock(guard, cond) and
pred = DataFlow::ssaDefinitionNode(input) and
succ = DataFlow::ssaDefinitionNode(phi) and
input = phi.getInputFromBlock(bb) and
guard.getEnclosingExpr() = cond.getTest() and
outcome = cond.getOutcome() and
barrierGuardBlocksExpr(guard, outcome, input.getAUse(), label) and
cond.dominates(bb)
barrierGuardBlocksExpr(guard, outcome, input.getAUse(), label)
)
}
/**
* Gets a basicblock that is dominated by `cond`, where the test for `cond` cond is `guard`.
*
* This predicate exists to get a better join-order for the `barrierGuardBlocksEdge` predicate above.
*/
private BasicBlock getADominatedBasicBlock(BarrierGuardNode guard, ConditionGuardNode cond) {
barrierGuardIsRelevant(guard) and
guard.getEnclosingExpr() = cond.getTest() and
cond.dominates(result)
}
/**
* Holds if there is a barrier edge `pred -> succ` in `cfg` either through an explicit barrier edge
* or one implied by a barrier guard.