@@ -474,20 +474,29 @@ pragma[nomagic]
474474private predicate barrierGuardBlocksEdge (
475475 BarrierGuardNode guard , DataFlow:: Node pred , DataFlow:: Node succ , string label
476476) {
477- barrierGuardIsRelevant ( guard ) and
478477 exists (
479478 SsaVariable input , SsaPhiNode phi , BasicBlock bb , ConditionGuardNode cond , boolean outcome
480479 |
480+ bb = getADominatedBasicBlock ( guard , cond ) and
481481 pred = DataFlow:: ssaDefinitionNode ( input ) and
482482 succ = DataFlow:: ssaDefinitionNode ( phi ) and
483483 input = phi .getInputFromBlock ( bb ) and
484- guard .getEnclosingExpr ( ) = cond .getTest ( ) and
485484 outcome = cond .getOutcome ( ) and
486- barrierGuardBlocksExpr ( guard , outcome , input .getAUse ( ) , label ) and
487- cond .dominates ( bb )
485+ barrierGuardBlocksExpr ( guard , outcome , input .getAUse ( ) , label )
488486 )
489487}
490488
489+ /**
490+ * Gets a basicblock that is dominated by `cond`, where the test for `cond` cond is `guard`.
491+ *
492+ * This predicate exists to get a better join-order for the `barrierGuardBlocksEdge` predicate above.
493+ */
494+ private BasicBlock getADominatedBasicBlock ( BarrierGuardNode guard , ConditionGuardNode cond ) {
495+ barrierGuardIsRelevant ( guard ) and
496+ guard .getEnclosingExpr ( ) = cond .getTest ( ) and
497+ cond .dominates ( result )
498+ }
499+
491500/**
492501 * Holds if there is a barrier edge `pred -> succ` in `cfg` either through an explicit barrier edge
493502 * or one implied by a barrier guard.
0 commit comments