@@ -275,9 +275,12 @@ module AccessPath {
275
275
* Either the definition or a use of the SSA variable
276
276
*/
277
277
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 ( )
281
284
}
282
285
283
286
/**
@@ -341,13 +344,24 @@ module AccessPath {
341
344
if result = getBaseVar ( _) then usedInWrite = true else usedInWrite = false
342
345
}
343
346
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 ( ) {
346
353
// The variable might be used where `getLaterBaseAccess()` is called.
347
354
exists ( DataFlow:: Node node |
348
355
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 ( ) {
351
365
// There is a write that writes to the variable.
352
366
getBaseVar ( _) = getAVariableRef ( result ) and
353
367
// There is both a "write" and "read" in the same container of the variable.
@@ -364,7 +378,7 @@ module AccessPath {
364
378
getAVariableRef ( var ) = baseExpr and
365
379
var = getARelevantVariable ( ) and
366
380
writeNode = write .getWriteNode ( ) and
367
- writeNode . getBasicBlock ( ) . ( ReachableBasicBlock ) . strictlyDominates ( result ) and
381
+ result . getImmediateDominator + ( ) = writeNode . getBasicBlock ( ) and
368
382
// manual magic.
369
383
result = getAnAccessInContainer ( getARelevantVariable ( ) , _, false ) .getBasicBlock ( )
370
384
)
0 commit comments