@@ -530,15 +530,15 @@ predicate adjacentDefRead(DefOrUse defOrUse1, UseOrPhi use) {
530
530
exists ( IRBlock bb1 , int i1 , SourceVariable v |
531
531
defOrUse1 .asDefOrUse ( ) .hasIndexInBlock ( bb1 , i1 , v )
532
532
|
533
- exists ( IRBlock bb2 , int i2 , Definition def |
534
- adjacentDefRead ( pragma [ only_bind_into ] ( def ) , pragma [ only_bind_into ] ( bb1 ) ,
533
+ exists ( IRBlock bb2 , int i2 , DefinitionExt def |
534
+ adjacentDefReadExt ( pragma [ only_bind_into ] ( def ) , pragma [ only_bind_into ] ( bb1 ) ,
535
535
pragma [ only_bind_into ] ( i1 ) , pragma [ only_bind_into ] ( bb2 ) , pragma [ only_bind_into ] ( i2 ) ) and
536
536
def .getSourceVariable ( ) = v and
537
537
use .asDefOrUse ( ) .( UseImpl ) .hasIndexInBlock ( bb2 , i2 , v )
538
538
)
539
539
or
540
540
exists ( PhiNode phi |
541
- lastRefRedef ( _, bb1 , i1 , phi ) and
541
+ lastRefRedefExt ( _, bb1 , i1 , phi ) and
542
542
use .asPhi ( ) = phi and
543
543
phi .getSourceVariable ( ) = pragma [ only_bind_into ] ( v )
544
544
)
@@ -550,11 +550,18 @@ predicate adjacentDefRead(DefOrUse defOrUse1, UseOrPhi use) {
550
550
* flows to `useOrPhi`.
551
551
*/
552
552
private predicate globalDefToUse ( GlobalDef globalDef , UseOrPhi useOrPhi ) {
553
- exists ( IRBlock bb1 , int i1 , IRBlock bb2 , int i2 , SourceVariable v |
554
- globalDef .hasIndexInBlock ( bb1 , i1 , v ) and
555
- adjacentDefRead ( _, pragma [ only_bind_into ] ( bb1 ) , pragma [ only_bind_into ] ( i1 ) ,
556
- pragma [ only_bind_into ] ( bb2 ) , pragma [ only_bind_into ] ( i2 ) ) and
557
- useOrPhi .asDefOrUse ( ) .hasIndexInBlock ( bb2 , i2 , v )
553
+ exists ( IRBlock bb1 , int i1 , SourceVariable v | globalDef .hasIndexInBlock ( bb1 , i1 , v ) |
554
+ exists ( IRBlock bb2 , int i2 |
555
+ adjacentDefReadExt ( _, pragma [ only_bind_into ] ( bb1 ) , pragma [ only_bind_into ] ( i1 ) ,
556
+ pragma [ only_bind_into ] ( bb2 ) , pragma [ only_bind_into ] ( i2 ) ) and
557
+ useOrPhi .asDefOrUse ( ) .hasIndexInBlock ( bb2 , i2 , v )
558
+ )
559
+ or
560
+ exists ( PhiNode phi |
561
+ lastRefRedefExt ( _, bb1 , i1 , phi ) and
562
+ useOrPhi .asPhi ( ) = phi and
563
+ phi .getSourceVariable ( ) = pragma [ only_bind_into ] ( v )
564
+ )
558
565
)
559
566
}
560
567
@@ -666,17 +673,17 @@ private predicate ssaFlowImpl(SsaDefOrUse defOrUse, Node nodeFrom, Node nodeTo,
666
673
* Holds if `def` is the corresponding definition of
667
674
* the SSA library's `definition`.
668
675
*/
669
- private Definition ssaDefinition ( Def def ) {
676
+ private DefinitionExt ssaDefinition ( Def def ) {
670
677
exists ( IRBlock block , int i , SourceVariable sv |
671
678
def .hasIndexInBlock ( block , i , sv ) and
672
- result .definesAt ( sv , block , i )
679
+ result .definesAt ( sv , block , i , _ )
673
680
)
674
681
}
675
682
676
683
/** Gets a node that represents the prior definition of `node`. */
677
684
private Node getAPriorDefinition ( SsaDefOrUse defOrUse ) {
678
- exists ( IRBlock bb , int i , SourceVariable sv , Definition def , DefOrUse defOrUse0 |
679
- SsaCached :: lastRefRedef ( pragma [ only_bind_into ] ( def ) , pragma [ only_bind_into ] ( bb ) ,
685
+ exists ( IRBlock bb , int i , SourceVariable sv , DefinitionExt def , DefOrUse defOrUse0 |
686
+ lastRefRedefExt ( pragma [ only_bind_into ] ( def ) , pragma [ only_bind_into ] ( bb ) ,
680
687
pragma [ only_bind_into ] ( i ) , ssaDefinition ( defOrUse ) ) and
681
688
def .getSourceVariable ( ) = sv and
682
689
defOrUse0 .hasIndexInBlock ( bb , i , sv ) and
@@ -702,7 +709,7 @@ pragma[nomagic]
702
709
private predicate fromPhiNodeToUse ( PhiNode phi , SourceVariable sv , IRBlock bb1 , int i1 , UseOrPhi use ) {
703
710
exists ( IRBlock bb2 , int i2 |
704
711
use .asDefOrUse ( ) .hasIndexInBlock ( bb2 , i2 , sv ) and
705
- adjacentDefRead ( pragma [ only_bind_into ] ( phi ) , pragma [ only_bind_into ] ( bb1 ) ,
712
+ adjacentDefReadExt ( pragma [ only_bind_into ] ( phi ) , pragma [ only_bind_into ] ( bb1 ) ,
706
713
pragma [ only_bind_into ] ( i1 ) , pragma [ only_bind_into ] ( bb2 ) , pragma [ only_bind_into ] ( i2 ) )
707
714
)
708
715
}
@@ -711,13 +718,13 @@ private predicate fromPhiNodeToUse(PhiNode phi, SourceVariable sv, IRBlock bb1,
711
718
predicate fromPhiNode ( SsaPhiNode nodeFrom , Node nodeTo ) {
712
719
exists ( PhiNode phi , SourceVariable sv , IRBlock bb1 , int i1 , UseOrPhi use |
713
720
phi = nodeFrom .getPhiNode ( ) and
714
- phi .definesAt ( sv , bb1 , i1 ) and
721
+ phi .definesAt ( sv , bb1 , i1 , _ ) and
715
722
useToNode ( use , nodeTo )
716
723
|
717
724
fromPhiNodeToUse ( phi , sv , bb1 , i1 , use )
718
725
or
719
726
exists ( PhiNode phiTo |
720
- lastRefRedef ( phi , _, _, phiTo ) and
727
+ lastRefRedefExt ( phi , _, _, phiTo ) and
721
728
nodeTo .( SsaPhiNode ) .getPhiNode ( ) = phiTo
722
729
)
723
730
)
@@ -796,8 +803,8 @@ module SsaCached {
796
803
* path between them without any read of `def`.
797
804
*/
798
805
cached
799
- predicate adjacentDefRead ( Definition def , IRBlock bb1 , int i1 , IRBlock bb2 , int i2 ) {
800
- SsaImpl:: adjacentDefRead ( def , bb1 , i1 , bb2 , i2 )
806
+ predicate adjacentDefReadExt ( DefinitionExt def , IRBlock bb1 , int i1 , IRBlock bb2 , int i2 ) {
807
+ SsaImpl:: adjacentDefReadExt ( def , _ , bb1 , i1 , bb2 , i2 )
801
808
}
802
809
803
810
/**
@@ -806,8 +813,8 @@ module SsaCached {
806
813
* without passing through another read or write.
807
814
*/
808
815
cached
809
- predicate lastRefRedef ( Definition def , IRBlock bb , int i , Definition next ) {
810
- SsaImpl:: lastRefRedef ( def , bb , i , next )
816
+ predicate lastRefRedefExt ( DefinitionExt def , IRBlock bb , int i , DefinitionExt next ) {
817
+ SsaImpl:: lastRefRedefExt ( def , _ , bb , i , next )
811
818
}
812
819
}
813
820
@@ -818,8 +825,8 @@ private newtype TSsaDefOrUse =
818
825
or
819
826
// Like in the pruning stage, we only include definition that's live after the
820
827
// write as the final definitions computed by SSA.
821
- exists ( Definition def , SourceVariable sv , IRBlock bb , int i |
822
- def .definesAt ( sv , bb , i ) and
828
+ exists ( DefinitionExt def , SourceVariable sv , IRBlock bb , int i |
829
+ def .definesAt ( sv , bb , i , _ ) and
823
830
defOrUse .( DefImpl ) .hasIndexInBlock ( bb , i , sv )
824
831
)
825
832
} or
@@ -967,9 +974,14 @@ class Def extends DefOrUse {
967
974
968
975
private module SsaImpl = SsaImplCommon:: Make< SsaInput > ;
969
976
970
- class PhiNode = SsaImpl:: PhiNode ;
977
+ class PhiNode extends SsaImpl:: DefinitionExt {
978
+ PhiNode ( ) {
979
+ this instanceof SsaImpl:: PhiNode or
980
+ this instanceof SsaImpl:: PhiReadNode
981
+ }
982
+ }
971
983
972
- class Definition = SsaImpl:: Definition ;
984
+ class DefinitionExt = SsaImpl:: DefinitionExt ;
973
985
974
986
class UncertainWriteDefinition = SsaImpl:: UncertainWriteDefinition ;
975
987
0 commit comments