@@ -8,91 +8,75 @@ import java
88 * Predicates for basic-block-level dominance.
99 */
1010
11- /** Entry points for control-flow. */
12- private predicate flowEntry ( BasicBlock entry ) {
13- exists ( Stmt entrystmt | entrystmt = entry .getFirstNode ( ) .asStmt ( ) |
14- exists ( Callable c | entrystmt = c .getBody ( ) )
15- or
16- // This disjunct is technically superfluous, but safeguards against extractor problems.
17- entrystmt instanceof BlockStmt and
18- not exists ( entry .getEnclosingCallable ( ) ) and
19- not entrystmt .getParent ( ) instanceof Stmt
20- )
21- }
22-
23- /** The successor relation for basic blocks. */
24- private predicate bbSucc ( BasicBlock pre , BasicBlock post ) { post = pre .getABBSuccessor ( ) }
25-
26- /** The immediate dominance relation for basic blocks. */
27- cached
28- predicate bbIDominates ( BasicBlock dom , BasicBlock node ) =
29- idominance( flowEntry / 1 , bbSucc / 2 ) ( _, dom , node )
30-
31- /** Holds if the dominance relation is calculated for `bb`. */
32- predicate hasDominanceInformation ( BasicBlock bb ) {
33- exists ( BasicBlock entry | flowEntry ( entry ) and bbSucc * ( entry , bb ) )
11+ /**
12+ * DEPRECATED: Use `BasicBlock::immediatelyDominates` instead.
13+ *
14+ * The immediate dominance relation for basic blocks.
15+ */
16+ deprecated predicate bbIDominates ( BasicBlock dom , BasicBlock node ) {
17+ dom .immediatelyDominates ( node )
3418}
3519
3620/** Exit points for basic-block control-flow. */
3721private predicate bbSink ( BasicBlock exit ) { exit .getLastNode ( ) instanceof ControlFlow:: ExitNode }
3822
3923/** Reversed `bbSucc`. */
40- private predicate bbPred ( BasicBlock post , BasicBlock pre ) { post = pre .getABBSuccessor ( ) }
24+ private predicate bbPred ( BasicBlock post , BasicBlock pre ) { post = pre .getASuccessor ( ) }
4125
4226/** The immediate post-dominance relation on basic blocks. */
43- cached
44- predicate bbIPostDominates ( BasicBlock dominator , BasicBlock node ) =
27+ deprecated predicate bbIPostDominates ( BasicBlock dominator , BasicBlock node ) =
4528 idominance( bbSink / 1 , bbPred / 2 ) ( _, dominator , node )
4629
47- /** Holds if `dom` strictly dominates `node`. */
48- predicate bbStrictlyDominates ( BasicBlock dom , BasicBlock node ) { bbIDominates + ( dom , node ) }
49-
50- /** Holds if `dom` dominates `node`. (This is reflexive.) */
51- predicate bbDominates ( BasicBlock dom , BasicBlock node ) {
52- bbStrictlyDominates ( dom , node ) or dom = node
30+ /**
31+ * DEPRECATED: Use `BasicBlock::strictlyDominates` instead.
32+ *
33+ * Holds if `dom` strictly dominates `node`.
34+ */
35+ deprecated predicate bbStrictlyDominates ( BasicBlock dom , BasicBlock node ) {
36+ dom .strictlyDominates ( node )
5337}
5438
55- /** Holds if `dom` strictly post-dominates `node`. */
56- predicate bbStrictlyPostDominates ( BasicBlock dom , BasicBlock node ) { bbIPostDominates + ( dom , node ) }
39+ /**
40+ * DEPRECATED: Use `BasicBlock::dominates` instead.
41+ *
42+ * Holds if `dom` dominates `node`. (This is reflexive.)
43+ */
44+ deprecated predicate bbDominates ( BasicBlock dom , BasicBlock node ) { dom .dominates ( node ) }
5745
58- /** Holds if `dom` post-dominates `node`. (This is reflexive.) */
59- predicate bbPostDominates ( BasicBlock dom , BasicBlock node ) {
60- bbStrictlyPostDominates ( dom , node ) or dom = node
46+ /**
47+ * DEPRECATED: Use `BasicBlock::strictlyPostDominates` instead.
48+ *
49+ * Holds if `dom` strictly post-dominates `node`.
50+ */
51+ deprecated predicate bbStrictlyPostDominates ( BasicBlock dom , BasicBlock node ) {
52+ dom .strictlyPostDominates ( node )
6153}
6254
55+ /**
56+ * DEPRECATED: Use `BasicBlock::postDominates` instead.
57+ *
58+ * Holds if `dom` post-dominates `node`. (This is reflexive.)
59+ */
60+ deprecated predicate bbPostDominates ( BasicBlock dom , BasicBlock node ) { dom .postDominates ( node ) }
61+
6362/**
6463 * The dominance frontier relation for basic blocks.
6564 *
6665 * This is equivalent to:
6766 *
6867 * ```
69- * bbDominates(x, w.getABBPredecessor ()) and not bbStrictlyDominates(x, w)
68+ * x.dominates(w.getAPredecessor ()) and not x.strictlyDominates( w)
7069 * ```
7170 */
7271predicate dominanceFrontier ( BasicBlock x , BasicBlock w ) {
73- x = w .getABBPredecessor ( ) and not bbIDominates ( x , w )
72+ x = w .getAPredecessor ( ) and not x . immediatelyDominates ( w )
7473 or
7574 exists ( BasicBlock prev | dominanceFrontier ( prev , w ) |
76- bbIDominates ( x , prev ) and
77- not bbIDominates ( x , w )
75+ x . immediatelyDominates ( prev ) and
76+ not x . immediatelyDominates ( w )
7877 )
7978}
8079
81- /**
82- * Holds if `(bb1, bb2)` is an edge that dominates `bb2`, that is, all other
83- * predecessors of `bb2` are dominated by `bb2`. This implies that `bb1` is the
84- * immediate dominator of `bb2`.
85- *
86- * This is a necessary and sufficient condition for an edge to dominate anything,
87- * and in particular `dominatingEdge(bb1, bb2) and bb2.bbDominates(bb3)` means
88- * that the edge `(bb1, bb2)` dominates `bb3`.
89- */
90- predicate dominatingEdge ( BasicBlock bb1 , BasicBlock bb2 ) {
91- bbIDominates ( bb1 , bb2 ) and
92- bb1 .getABBSuccessor ( ) = bb2 and
93- forall ( BasicBlock pred | pred = bb2 .getABBPredecessor ( ) and pred != bb1 | bbDominates ( bb2 , pred ) )
94- }
95-
9680/*
9781 * Predicates for expression-level dominance.
9882 */
@@ -102,7 +86,7 @@ predicate iDominates(ControlFlowNode dominator, ControlFlowNode node) {
10286 exists ( BasicBlock bb , int i | dominator = bb .getNode ( i ) and node = bb .getNode ( i + 1 ) )
10387 or
10488 exists ( BasicBlock dom , BasicBlock bb |
105- bbIDominates ( dom , bb ) and
89+ dom . immediatelyDominates ( bb ) and
10690 dominator = dom .getLastNode ( ) and
10791 node = bb .getFirstNode ( )
10892 )
@@ -112,7 +96,7 @@ predicate iDominates(ControlFlowNode dominator, ControlFlowNode node) {
11296pragma [ inline]
11397predicate strictlyDominates ( ControlFlowNode dom , ControlFlowNode node ) {
11498 // This predicate is gigantic, so it must be inlined.
115- bbStrictlyDominates ( dom .getBasicBlock ( ) , node .getBasicBlock ( ) )
99+ dom .getBasicBlock ( ) . strictlyDominates ( node .getBasicBlock ( ) )
116100 or
117101 exists ( BasicBlock b , int i , int j | dom = b .getNode ( i ) and node = b .getNode ( j ) and i < j )
118102}
@@ -121,7 +105,7 @@ predicate strictlyDominates(ControlFlowNode dom, ControlFlowNode node) {
121105pragma [ inline]
122106predicate dominates ( ControlFlowNode dom , ControlFlowNode node ) {
123107 // This predicate is gigantic, so it must be inlined.
124- bbStrictlyDominates ( dom .getBasicBlock ( ) , node .getBasicBlock ( ) )
108+ dom .getBasicBlock ( ) . strictlyDominates ( node .getBasicBlock ( ) )
125109 or
126110 exists ( BasicBlock b , int i , int j | dom = b .getNode ( i ) and node = b .getNode ( j ) and i <= j )
127111}
@@ -130,7 +114,7 @@ predicate dominates(ControlFlowNode dom, ControlFlowNode node) {
130114pragma [ inline]
131115predicate strictlyPostDominates ( ControlFlowNode dom , ControlFlowNode node ) {
132116 // This predicate is gigantic, so it must be inlined.
133- bbStrictlyPostDominates ( dom .getBasicBlock ( ) , node .getBasicBlock ( ) )
117+ dom .getBasicBlock ( ) . strictlyPostDominates ( node .getBasicBlock ( ) )
134118 or
135119 exists ( BasicBlock b , int i , int j | dom = b .getNode ( i ) and node = b .getNode ( j ) and i > j )
136120}
@@ -139,7 +123,7 @@ predicate strictlyPostDominates(ControlFlowNode dom, ControlFlowNode node) {
139123pragma [ inline]
140124predicate postDominates ( ControlFlowNode dom , ControlFlowNode node ) {
141125 // This predicate is gigantic, so it must be inlined.
142- bbStrictlyPostDominates ( dom .getBasicBlock ( ) , node .getBasicBlock ( ) )
126+ dom .getBasicBlock ( ) . strictlyPostDominates ( node .getBasicBlock ( ) )
143127 or
144128 exists ( BasicBlock b , int i , int j | dom = b .getNode ( i ) and node = b .getNode ( j ) and i >= j )
145129}
0 commit comments