@@ -420,6 +420,24 @@ 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 (
430+ BarrierGuardNode guard , ConditionGuardNode cond , boolean outcome
431+ ) {
432+ barrierGuardIsRelevant ( guard ) and
433+ outcome = cond .getOutcome ( ) and
434+ (
435+ cond .getTest ( ) = guard .getEnclosingExpr ( )
436+ or
437+ cond .getTest ( ) .flow ( ) .getImmediatePredecessor + ( ) = guard
438+ )
439+ }
440+
423441/**
424442 * Holds if data flow node `nd` acts as a barrier for data flow, possibly due to aliasing
425443 * through an access path.
@@ -435,14 +453,9 @@ private predicate barrierGuardBlocksNode(BarrierGuardNode guard, DataFlow::Node
435453 )
436454 or
437455 // 2) `nd` is an instance of an access path `p`, and dominated by a barrier for `p`
438- barrierGuardIsRelevant ( guard ) and
439456 exists ( AccessPath p , BasicBlock bb , ConditionGuardNode cond , boolean outcome |
440457 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
458+ barrierGuardUsedInCondition ( guard , cond , outcome ) and
446459 barrierGuardBlocksAccessPath ( guard , outcome , p , label ) and
447460 cond .dominates ( bb )
448461 )
0 commit comments