@@ -490,7 +490,7 @@ module FlowVar_internal {
490
490
exists ( VariableAccess va |
491
491
va .getTarget ( ) = result and
492
492
readAccess ( va ) and
493
- bbNotInLoop ( va .getBasicBlock ( ) )
493
+ exists ( BasicBlock bb | bb = va .getBasicBlock ( ) | not this . bbInLoop ( bb ) )
494
494
)
495
495
}
496
496
@@ -513,10 +513,8 @@ module FlowVar_internal {
513
513
bbInLoopCondition ( bb )
514
514
}
515
515
516
- predicate bbNotInLoop ( BasicBlock bb ) {
517
- not this .bbInLoop ( bb ) and
518
- bb .getEnclosingFunction ( ) = this .getEnclosingFunction ( )
519
- }
516
+ /** Holds if `sbb` is inside this loop. */
517
+ predicate sbbInLoop ( SubBasicBlock sbb ) { this .bbInLoop ( sbb .getBasicBlock ( ) ) }
520
518
521
519
/**
522
520
* Holds if `bb` is a basic block inside this loop where `v` has not been
@@ -537,22 +535,19 @@ module FlowVar_internal {
537
535
}
538
536
539
537
/**
540
- * Holds if some loop always assigns to `v` before leaving through an edge
541
- * from `bbInside` in its condition to `bbOutside` outside the loop, where
542
- * (`sbbDef`, `v`) is a `BlockVar` defined outside the loop. Also, `v` must
543
- * be used outside the loop.
538
+ * Holds if `loop` always assigns to `v` before leaving through an edge
539
+ * from `bbInside` in its condition to `bbOutside` outside the loop. Also,
540
+ * `v` must be used outside the loop.
544
541
*/
545
542
predicate skipLoop (
546
- SubBasicBlock sbbInside , SubBasicBlock sbbOutside , SubBasicBlock sbbDef , Variable v
543
+ SubBasicBlock sbbInside , SubBasicBlock sbbOutside , Variable v , AlwaysTrueUponEntryLoop loop
547
544
) {
548
- exists ( AlwaysTrueUponEntryLoop loop , BasicBlock bbInside , BasicBlock bbOutside |
545
+ exists ( BasicBlock bbInside , BasicBlock bbOutside |
549
546
loop .alwaysAssignsBeforeLeavingCondition ( bbInside , bbOutside , v ) and
550
547
bbInside = sbbInside .getBasicBlock ( ) and
551
548
bbOutside = sbbOutside .getBasicBlock ( ) and
552
549
sbbInside .lastInBB ( ) and
553
- sbbOutside .firstInBB ( ) and
554
- loop .bbNotInLoop ( sbbDef .getBasicBlock ( ) ) and
555
- exists ( TBlockVar ( sbbDef , v ) )
550
+ sbbOutside .firstInBB ( )
556
551
)
557
552
}
558
553
@@ -571,7 +566,7 @@ module FlowVar_internal {
571
566
start = TBlockVar ( sbbDef , v ) and
572
567
result = mid .getASuccessor ( ) and
573
568
variableLiveInSBB ( result , v ) and
574
- not skipLoop ( mid , result , sbbDef , v ) and
569
+ forall ( AlwaysTrueUponEntryLoop loop | skipLoop ( mid , result , v , loop ) | loop . sbbInLoop ( sbbDef ) ) and
575
570
not assignmentLikeOperation ( result , v , _, _)
576
571
)
577
572
}
@@ -679,10 +674,11 @@ module FlowVar_internal {
679
674
predicate dominatedByOverwrite ( UninitializedLocalVariable v , VariableAccess va ) {
680
675
exists ( BasicBlock bb , int vaIndex |
681
676
va = bb .getNode ( vaIndex ) and
682
- va .getTarget ( ) = v
683
- |
677
+ va .getTarget ( ) = v and
684
678
vaIndex > indexOfFirstOverwriteInBB ( v , bb )
685
679
or
680
+ va = bb .getNode ( vaIndex ) and
681
+ va .getTarget ( ) = v and
686
682
bbStrictlyDominates ( getAnOverwritingBB ( v ) , bb )
687
683
)
688
684
}
0 commit comments