@@ -508,34 +508,15 @@ private module Cached {
508
508
Impl:: uncertainWriteDefinitionInput ( redef , def )
509
509
}
510
510
511
- pragma [ nomagic]
512
- private predicate defReaches ( Definition def , DataFlowIntegration:: Node node ) {
513
- exists ( DataFlowIntegration:: SsaDefinitionExtNode nodeFrom |
514
- nodeFrom .getDefinitionExt ( ) = def and
515
- DataFlowIntegrationImpl:: localFlowStep ( _, nodeFrom , node , false )
516
- )
517
- or
518
- exists ( DataFlowIntegration:: Node mid |
519
- defReaches ( def , mid ) and
520
- DataFlowIntegrationImpl:: localFlowStep ( _, mid , node , _)
521
- |
522
- // flow into phi input node
523
- mid instanceof DataFlowIntegration:: SsaInputNode
524
- or
525
- // flow into definition
526
- mid instanceof DataFlowIntegration:: SsaDefinitionExtNode
527
- )
528
- }
529
-
530
511
/**
531
512
* Holds if the value defined at `def` can reach `use` without passing through
532
513
* any other uses, but possibly through phi nodes and uncertain implicit updates.
533
514
*/
534
515
cached
535
516
predicate firstUse ( Definition def , VarRead use ) {
536
- exists ( DataFlowIntegration :: ExprNode nodeTo |
537
- nodeTo . getExpr ( ) = use and
538
- defReaches ( def , nodeTo )
517
+ exists ( BasicBlock bb , int i |
518
+ Impl :: firstUse ( def , bb , i , _ ) and
519
+ use . getControlFlowNode ( ) = bb . getNode ( i )
539
520
)
540
521
}
541
522
@@ -594,40 +575,17 @@ private module Cached {
594
575
595
576
cached
596
577
module SsaPublic {
597
- pragma [ nomagic]
598
- private predicate useReaches ( VarRead use , DataFlowIntegration:: Node node , boolean sameVar ) {
599
- exists ( DataFlowIntegration:: ExprNode nodeFrom |
600
- nodeFrom .getExpr ( ) = use and
601
- DataFlowIntegration:: localFlowStep ( _, nodeFrom , node , true ) and
602
- sameVar = true
603
- )
604
- or
605
- exists ( DataFlowIntegration:: Node mid , boolean sameVarMid |
606
- useReaches ( use , mid , sameVarMid ) and
607
- DataFlowIntegration:: localFlowStep ( _, mid , node , _)
608
- |
609
- exists ( Impl:: DefinitionExt def |
610
- // flow into definition
611
- def = mid .( DataFlowIntegration:: SsaDefinitionExtNode ) .getDefinitionExt ( )
612
- or
613
- // flow into phi input node
614
- def = mid .( DataFlowIntegration:: SsaInputNode ) .getDefinitionExt ( )
615
- |
616
- if def instanceof Impl:: PhiReadNode then sameVar = sameVarMid else sameVar = false
617
- )
618
- )
619
- }
620
-
621
578
/**
622
579
* Holds if `use1` and `use2` form an adjacent use-use-pair of the same SSA
623
580
* variable, that is, the value read in `use1` can reach `use2` without passing
624
581
* through any other use or any SSA definition of the variable.
625
582
*/
626
583
cached
627
584
predicate adjacentUseUseSameVar ( VarRead use1 , VarRead use2 ) {
628
- exists ( DataFlowIntegration:: ExprNode nodeTo |
629
- nodeTo .getExpr ( ) = use2 and
630
- useReaches ( use1 , nodeTo , true )
585
+ exists ( BasicBlock bb1 , int i1 , BasicBlock bb2 , int i2 |
586
+ use1 .getControlFlowNode ( ) = bb1 .getNode ( i1 ) and
587
+ use2 .getControlFlowNode ( ) = bb2 .getNode ( i2 ) and
588
+ Impl:: adjacentUseUse ( bb1 , i1 , bb2 , i2 , _, true )
631
589
)
632
590
}
633
591
@@ -639,9 +597,10 @@ private module Cached {
639
597
*/
640
598
cached
641
599
predicate adjacentUseUse ( VarRead use1 , VarRead use2 ) {
642
- exists ( DataFlowIntegration:: ExprNode nodeTo |
643
- nodeTo .getExpr ( ) = use2 and
644
- useReaches ( use1 , nodeTo , _)
600
+ exists ( BasicBlock bb1 , int i1 , BasicBlock bb2 , int i2 |
601
+ use1 .getControlFlowNode ( ) = bb1 .getNode ( i1 ) and
602
+ use2 .getControlFlowNode ( ) = bb2 .getNode ( i2 ) and
603
+ Impl:: adjacentUseUse ( bb1 , i1 , bb2 , i2 , _, _)
645
604
)
646
605
}
647
606
}
0 commit comments