@@ -359,13 +359,17 @@ module Make<LocationSig Location, InputSig<Location> Input> {
359
359
* either a read (when `k` is `SsaActualRead()`) or an SSA definition (when
360
360
* `k` is `SsaDef()`).
361
361
*
362
- * Unlike `Liveness::ref`, this includes `phi` nodes.
362
+ * Unlike `Liveness::ref`, this includes `phi` nodes and pseudo-reads
363
+ * associated with uncertain writes.
363
364
*/
364
365
pragma [ nomagic]
365
366
predicate ssaRef ( BasicBlock bb , int i , SourceVariable v , SsaRefKind k ) {
366
367
variableRead ( bb , i , v , _) and
367
368
k = SsaActualRead ( )
368
369
or
370
+ variableWrite ( bb , i , v , false ) and
371
+ k = SsaActualRead ( )
372
+ or
369
373
any ( Definition def ) .definesAt ( v , bb , i ) and
370
374
k = SsaDef ( )
371
375
}
@@ -483,6 +487,13 @@ module Make<LocationSig Location, InputSig<Location> Input> {
483
487
ssaDefReachesEndOfBlock ( getImmediateBasicBlockDominator ( bb ) , def , v ) and
484
488
not ssaDefReachesReadWithinBlock ( v , _, bb , i )
485
489
}
490
+
491
+ predicate uncertainWriteDefinitionInput ( UncertainWriteDefinition def , Definition inp ) {
492
+ exists ( SourceVariable v , BasicBlock bb , int i |
493
+ def .definesAt ( v , bb , i ) and
494
+ ssaDefReachesRead ( v , inp , bb , i )
495
+ )
496
+ }
486
497
}
487
498
488
499
private module SsaDefReaches {
@@ -861,7 +872,10 @@ module Make<LocationSig Location, InputSig<Location> Input> {
861
872
*
862
873
* Same as `ssaDefReachesReadExt`, but ignores phi-reads.
863
874
*/
864
- predicate ssaDefReachesRead = SsaDefReachesNew:: ssaDefReachesRead / 4 ;
875
+ predicate ssaDefReachesRead ( SourceVariable v , Definition def , BasicBlock bb , int i ) {
876
+ SsaDefReachesNew:: ssaDefReachesRead ( v , def , bb , i ) and
877
+ variableRead ( bb , i , v , _)
878
+ }
865
879
866
880
/**
867
881
* NB: If this predicate is exposed, it should be cached.
@@ -994,10 +1008,7 @@ module Make<LocationSig Location, InputSig<Location> Input> {
994
1008
* `def`. Since `def` is uncertain, the value from the preceding definition might
995
1009
* still be valid.
996
1010
*/
997
- pragma [ nomagic]
998
- predicate uncertainWriteDefinitionInput ( UncertainWriteDefinition def , Definition inp ) {
999
- lastRefRedef ( inp , _, _, def )
1000
- }
1011
+ predicate uncertainWriteDefinitionInput = SsaDefReachesNew:: uncertainWriteDefinitionInput / 2 ;
1001
1012
1002
1013
/** Holds if `bb` is a control-flow exit point. */
1003
1014
private predicate exitBlock ( BasicBlock bb ) { not exists ( getABasicBlockSuccessor ( bb ) ) }
0 commit comments