@@ -420,6 +420,22 @@ private predicate barrierGuardBlocksSsaRefinement(
420420 )
421421}
422422
423+ /**
424+ * Holds if the result of `guard` is used in the branching condition `cond`.
425+ *
426+ * `outcome` is bound to the outcome of `cond` for join-ordering purposes.
427+ */
428+ pragma [ noinline]
429+ private predicate barrierGuardUsedInCondition ( BarrierGuardNode guard , ConditionGuardNode cond , boolean outcome ) {
430+ barrierGuardIsRelevant ( guard ) and
431+ outcome = cond .getOutcome ( ) and
432+ (
433+ cond .getTest ( ) = guard .getEnclosingExpr ( )
434+ or
435+ cond .getTest ( ) .flow ( ) .getImmediatePredecessor + ( ) = guard
436+ )
437+ }
438+
423439/**
424440 * Holds if data flow node `nd` acts as a barrier for data flow, possibly due to aliasing
425441 * through an access path.
@@ -435,14 +451,9 @@ private predicate barrierGuardBlocksNode(BarrierGuardNode guard, DataFlow::Node
435451 )
436452 or
437453 // 2) `nd` is an instance of an access path `p`, and dominated by a barrier for `p`
438- barrierGuardIsRelevant ( guard ) and
439454 exists ( AccessPath p , BasicBlock bb , ConditionGuardNode cond , boolean outcome |
440455 nd = DataFlow:: valueNode ( p .getAnInstanceIn ( bb ) ) and
441- (
442- guard .getEnclosingExpr ( ) = cond .getTest ( ) or
443- guard = cond .getTest ( ) .flow ( ) .getImmediatePredecessor + ( )
444- ) and
445- outcome = cond .getOutcome ( ) and
456+ barrierGuardUsedInCondition ( guard , cond , outcome ) and
446457 barrierGuardBlocksAccessPath ( guard , outcome , p , label ) and
447458 cond .dominates ( bb )
448459 )
0 commit comments