@@ -8,91 +8,75 @@ import java
8
8
* Predicates for basic-block-level dominance.
9
9
*/
10
10
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 )
34
18
}
35
19
36
20
/** Exit points for basic-block control-flow. */
37
21
private predicate bbSink ( BasicBlock exit ) { exit .getLastNode ( ) instanceof ControlFlow:: ExitNode }
38
22
39
23
/** Reversed `bbSucc`. */
40
- private predicate bbPred ( BasicBlock post , BasicBlock pre ) { post = pre .getABBSuccessor ( ) }
24
+ private predicate bbPred ( BasicBlock post , BasicBlock pre ) { post = pre .getASuccessor ( ) }
41
25
42
26
/** 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 ) =
45
28
idominance( bbSink / 1 , bbPred / 2 ) ( _, dominator , node )
46
29
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 )
53
37
}
54
38
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 ) }
57
45
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 )
61
53
}
62
54
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
+
63
62
/**
64
63
* The dominance frontier relation for basic blocks.
65
64
*
66
65
* This is equivalent to:
67
66
*
68
67
* ```
69
- * bbDominates(x, w.getABBPredecessor ()) and not bbStrictlyDominates(x, w)
68
+ * x.dominates(w.getAPredecessor ()) and not x.strictlyDominates( w)
70
69
* ```
71
70
*/
72
71
predicate dominanceFrontier ( BasicBlock x , BasicBlock w ) {
73
- x = w .getABBPredecessor ( ) and not bbIDominates ( x , w )
72
+ x = w .getAPredecessor ( ) and not x . immediatelyDominates ( w )
74
73
or
75
74
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 )
78
77
)
79
78
}
80
79
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
-
96
80
/*
97
81
* Predicates for expression-level dominance.
98
82
*/
@@ -102,7 +86,7 @@ predicate iDominates(ControlFlowNode dominator, ControlFlowNode node) {
102
86
exists ( BasicBlock bb , int i | dominator = bb .getNode ( i ) and node = bb .getNode ( i + 1 ) )
103
87
or
104
88
exists ( BasicBlock dom , BasicBlock bb |
105
- bbIDominates ( dom , bb ) and
89
+ dom . immediatelyDominates ( bb ) and
106
90
dominator = dom .getLastNode ( ) and
107
91
node = bb .getFirstNode ( )
108
92
)
@@ -112,7 +96,7 @@ predicate iDominates(ControlFlowNode dominator, ControlFlowNode node) {
112
96
pragma [ inline]
113
97
predicate strictlyDominates ( ControlFlowNode dom , ControlFlowNode node ) {
114
98
// This predicate is gigantic, so it must be inlined.
115
- bbStrictlyDominates ( dom .getBasicBlock ( ) , node .getBasicBlock ( ) )
99
+ dom .getBasicBlock ( ) . strictlyDominates ( node .getBasicBlock ( ) )
116
100
or
117
101
exists ( BasicBlock b , int i , int j | dom = b .getNode ( i ) and node = b .getNode ( j ) and i < j )
118
102
}
@@ -121,7 +105,7 @@ predicate strictlyDominates(ControlFlowNode dom, ControlFlowNode node) {
121
105
pragma [ inline]
122
106
predicate dominates ( ControlFlowNode dom , ControlFlowNode node ) {
123
107
// This predicate is gigantic, so it must be inlined.
124
- bbStrictlyDominates ( dom .getBasicBlock ( ) , node .getBasicBlock ( ) )
108
+ dom .getBasicBlock ( ) . strictlyDominates ( node .getBasicBlock ( ) )
125
109
or
126
110
exists ( BasicBlock b , int i , int j | dom = b .getNode ( i ) and node = b .getNode ( j ) and i <= j )
127
111
}
@@ -130,7 +114,7 @@ predicate dominates(ControlFlowNode dom, ControlFlowNode node) {
130
114
pragma [ inline]
131
115
predicate strictlyPostDominates ( ControlFlowNode dom , ControlFlowNode node ) {
132
116
// This predicate is gigantic, so it must be inlined.
133
- bbStrictlyPostDominates ( dom .getBasicBlock ( ) , node .getBasicBlock ( ) )
117
+ dom .getBasicBlock ( ) . strictlyPostDominates ( node .getBasicBlock ( ) )
134
118
or
135
119
exists ( BasicBlock b , int i , int j | dom = b .getNode ( i ) and node = b .getNode ( j ) and i > j )
136
120
}
@@ -139,7 +123,7 @@ predicate strictlyPostDominates(ControlFlowNode dom, ControlFlowNode node) {
139
123
pragma [ inline]
140
124
predicate postDominates ( ControlFlowNode dom , ControlFlowNode node ) {
141
125
// This predicate is gigantic, so it must be inlined.
142
- bbStrictlyPostDominates ( dom .getBasicBlock ( ) , node .getBasicBlock ( ) )
126
+ dom .getBasicBlock ( ) . strictlyPostDominates ( node .getBasicBlock ( ) )
143
127
or
144
128
exists ( BasicBlock b , int i , int j | dom = b .getNode ( i ) and node = b .getNode ( j ) and i >= j )
145
129
}
0 commit comments