@@ -275,9 +275,12 @@ module AccessPath {
275275 * Either the definition or a use of the SSA variable
276276 */
277277 private VarRef getAVariableRef ( SsaVariable variable ) {
278- result = variable .getAUse ( )
279- or
280- result = variable .getDefinition ( ) .( SsaExplicitDefinition ) .getDef ( ) .getTarget ( )
278+ (
279+ result = variable .getAUse ( )
280+ or
281+ result = variable .getDefinition ( ) .( SsaExplicitDefinition ) .getDef ( ) .getTarget ( )
282+ ) and
283+ variable = getARelevantVariableSimple ( )
281284 }
282285
283286 /**
@@ -341,13 +344,24 @@ module AccessPath {
341344 if result = getBaseVar ( _) then usedInWrite = true else usedInWrite = false
342345 }
343346
344- /** Gets a variable that is relevant for the computations in the `GetLaterAccess` module. */
345- private SsaVariable getARelevantVariable ( ) {
347+ /**
348+ * Gets a variable that is relevant for the computations in the `GetLaterAccess` module.
349+ * This predicate restricts as much as it can, but without depending on `getAVariableRef`.
350+ */
351+ pragma [ inline]
352+ private SsaVariable getARelevantVariableSimple ( ) {
346353 // The variable might be used where `getLaterBaseAccess()` is called.
347354 exists ( DataFlow:: Node node |
348355 exists ( fromRhs ( node , _) ) and
349- node .asExpr ( ) = getAVariableRef ( result )
350- ) and
356+ node .asExpr ( ) = result .getAUse ( )
357+ )
358+ }
359+
360+ /**
361+ * Gets a variable that is relevant for the computations in the `GetLaterAccess` module.
362+ * This predicate depends on `getAVariableRef`, which in turn depends on `getARelevantVariableSimple`.
363+ */
364+ private SsaVariable getARelevantVariable ( ) {
351365 // There is a write that writes to the variable.
352366 getBaseVar ( _) = getAVariableRef ( result ) and
353367 // There is both a "write" and "read" in the same container of the variable.
@@ -364,7 +378,7 @@ module AccessPath {
364378 getAVariableRef ( var ) = baseExpr and
365379 var = getARelevantVariable ( ) and
366380 writeNode = write .getWriteNode ( ) and
367- writeNode . getBasicBlock ( ) . ( ReachableBasicBlock ) . strictlyDominates ( result ) and
381+ result . getImmediateDominator + ( ) = writeNode . getBasicBlock ( ) and
368382 // manual magic.
369383 result = getAnAccessInContainer ( getARelevantVariable ( ) , _, false ) .getBasicBlock ( )
370384 )
0 commit comments