@@ -19,18 +19,18 @@ private module Cached {
1919 * (certain or uncertain) writes.
2020 */
2121 private newtype TRefKind =
22- Read ( ReadKind rk ) or
22+ Read ( ) or
2323 Write ( boolean certain ) { certain = true or certain = false }
2424
2525 private class RefKind extends TRefKind {
2626 string toString ( ) {
27- exists ( ReadKind rk | this = Read ( rk ) and result = "read (" + rk + ")" )
27+ this = Read ( ) and result = "read"
2828 or
2929 exists ( boolean certain | this = Write ( certain ) and result = "write (" + certain + ")" )
3030 }
3131
3232 int getOrder ( ) {
33- this = Read ( _ ) and
33+ this = Read ( ) and
3434 result = 0
3535 or
3636 this = Write ( _) and
@@ -42,7 +42,7 @@ private module Cached {
4242 * Holds if the `i`th node of basic block `bb` is a reference to `v` of kind `k`.
4343 */
4444 private predicate ref ( BasicBlock bb , int i , SourceVariable v , RefKind k ) {
45- exists ( ReadKind rk | variableRead ( bb , i , v , rk ) | k = Read ( rk ) )
45+ variableRead ( bb , i , v ) and k = Read ( )
4646 or
4747 exists ( boolean certain | variableWrite ( bb , i , v , certain ) | k = Write ( certain ) )
4848 }
@@ -94,40 +94,38 @@ private module Cached {
9494
9595 /**
9696 * Holds if source variable `v` is live at the beginning of basic block `bb`.
97- * The read that witnesses the liveness of `v` is of kind `rk`.
9897 */
99- predicate liveAtEntry ( BasicBlock bb , SourceVariable v , ReadKind rk ) {
98+ predicate liveAtEntry ( BasicBlock bb , SourceVariable v ) {
10099 // The first read or certain write to `v` inside `bb` is a read
101- refRank ( bb , _, v , Read ( rk ) ) = firstReadOrCertainWrite ( bb , v )
100+ refRank ( bb , _, v , Read ( ) ) = firstReadOrCertainWrite ( bb , v )
102101 or
103102 // There is no certain write to `v` inside `bb`, but `v` is live at entry
104103 // to a successor basic block of `bb`
105104 not exists ( firstReadOrCertainWrite ( bb , v ) ) and
106- liveAtExit ( bb , v , rk )
105+ liveAtExit ( bb , v )
107106 }
108107
109108 /**
110109 * Holds if source variable `v` is live at the end of basic block `bb`.
111- * The read that witnesses the liveness of `v` is of kind `rk`.
112110 */
113- predicate liveAtExit ( BasicBlock bb , SourceVariable v , ReadKind rk ) {
114- liveAtEntry ( getABasicBlockSuccessor ( bb ) , v , rk )
111+ predicate liveAtExit ( BasicBlock bb , SourceVariable v ) {
112+ liveAtEntry ( getABasicBlockSuccessor ( bb ) , v )
115113 }
116114
117115 /**
118116 * Holds if variable `v` is live in basic block `bb` at index `i`.
119117 * The rank of `i` is `rnk` as defined by `refRank()`.
120118 */
121- private predicate liveAtRank ( BasicBlock bb , int i , SourceVariable v , int rnk , ReadKind rk ) {
119+ private predicate liveAtRank ( BasicBlock bb , int i , SourceVariable v , int rnk ) {
122120 exists ( RefKind kind | rnk = refRank ( bb , i , v , kind ) |
123121 rnk = maxRefRank ( bb , v ) and
124- liveAtExit ( bb , v , rk )
122+ liveAtExit ( bb , v )
125123 or
126124 ref ( bb , i , v , kind ) and
127- kind = Read ( rk )
125+ kind = Read ( )
128126 or
129127 exists ( RefKind nextKind |
130- liveAtRank ( bb , _, v , rnk + 1 , rk ) and
128+ liveAtRank ( bb , _, v , rnk + 1 ) and
131129 rnk + 1 = refRank ( bb , _, v , nextKind ) and
132130 nextKind != Write ( true )
133131 )
@@ -136,11 +134,10 @@ private module Cached {
136134
137135 /**
138136 * Holds if variable `v` is live after the (certain or uncertain) write at
139- * index `i` inside basic block `bb`. The read that witnesses the liveness of
140- * `v` is of kind `rk`.
137+ * index `i` inside basic block `bb`.
141138 */
142- predicate liveAfterWrite ( BasicBlock bb , int i , SourceVariable v , ReadKind rk ) {
143- exists ( int rnk | rnk = refRank ( bb , i , v , Write ( _) ) | liveAtRank ( bb , i , v , rnk , rk ) )
139+ predicate liveAfterWrite ( BasicBlock bb , int i , SourceVariable v ) {
140+ exists ( int rnk | rnk = refRank ( bb , i , v , Write ( _) ) | liveAtRank ( bb , i , v , rnk ) )
144141 }
145142 }
146143
@@ -182,11 +179,11 @@ private module Cached {
182179 newtype TDefinition =
183180 TWriteDef ( SourceVariable v , BasicBlock bb , int i ) {
184181 variableWrite ( bb , i , v , _) and
185- liveAfterWrite ( bb , i , v , _ )
182+ liveAfterWrite ( bb , i , v )
186183 } or
187184 TPhiNode ( SourceVariable v , BasicBlock bb ) {
188185 inDefDominanceFrontier ( bb , v ) and
189- liveAtEntry ( bb , v , _ )
186+ liveAtEntry ( bb , v )
190187 }
191188
192189 private module SsaDefReaches {
@@ -223,7 +220,7 @@ private module Cached {
223220 * Unlike `Liveness::ref`, this includes `phi` nodes.
224221 */
225222 predicate ssaRef ( BasicBlock bb , int i , SourceVariable v , SsaRefKind k ) {
226- variableRead ( bb , i , v , _ ) and
223+ variableRead ( bb , i , v ) and
227224 k = SsaRead ( )
228225 or
229226 exists ( Definition def | def .definesAt ( v , bb , i ) ) and
@@ -287,16 +284,12 @@ private module Cached {
287284 /**
288285 * Holds if the SSA definition of `v` at `def` reaches index `i` in the same
289286 * basic block `bb`, without crossing another SSA definition of `v`.
290- *
291- * The read at `i` is of kind `rk`.
292287 */
293- predicate ssaDefReachesReadWithinBlock (
294- SourceVariable v , Definition def , BasicBlock bb , int i , ReadKind rk
295- ) {
288+ predicate ssaDefReachesReadWithinBlock ( SourceVariable v , Definition def , BasicBlock bb , int i ) {
296289 exists ( int rnk |
297290 ssaDefReachesRank ( bb , def , rnk , v ) and
298291 rnk = ssaRefRank ( bb , i , v , SsaRead ( ) ) and
299- variableRead ( bb , i , v , rk )
292+ variableRead ( bb , i , v )
300293 )
301294 }
302295
@@ -321,7 +314,7 @@ private module Cached {
321314 v = def .getSourceVariable ( ) and
322315 result = ssaRefRank ( bb , i , v , k ) and
323316 (
324- ssaDefReachesRead ( _, def , bb , i , _ )
317+ ssaDefReachesRead ( _, def , bb , i )
325318 or
326319 def .definesAt ( _, bb , i )
327320 )
@@ -362,7 +355,7 @@ private module Cached {
362355 predicate defAdjacentRead ( Definition def , BasicBlock bb1 , BasicBlock bb2 , int i2 ) {
363356 varBlockReaches ( def , bb1 , bb2 ) and
364357 ssaRefRank ( bb2 , i2 , def .getSourceVariable ( ) , SsaRead ( ) ) = 1 and
365- variableRead ( bb2 , i2 , _, _ )
358+ variableRead ( bb2 , i2 , _)
366359 }
367360 }
368361
@@ -390,11 +383,11 @@ private module Cached {
390383 predicate ssaDefReachesEndOfBlock ( BasicBlock bb , Definition def , SourceVariable v ) {
391384 exists ( int last | last = maxSsaRefRank ( bb , v ) |
392385 ssaDefReachesRank ( bb , def , last , v ) and
393- liveAtExit ( bb , v , _ )
386+ liveAtExit ( bb , v )
394387 )
395388 or
396389 ssaDefReachesEndOfBlockRec ( bb , def , v ) and
397- liveAtExit ( bb , v , _ ) and
390+ liveAtExit ( bb , v ) and
398391 not ssaRef ( bb , _, v , SsaDef ( ) )
399392 }
400393
@@ -404,12 +397,12 @@ private module Cached {
404397 * is of kind `rk`.
405398 */
406399 cached
407- predicate ssaDefReachesRead ( SourceVariable v , Definition def , BasicBlock bb , int i , ReadKind rk ) {
408- ssaDefReachesReadWithinBlock ( v , def , bb , i , rk )
400+ predicate ssaDefReachesRead ( SourceVariable v , Definition def , BasicBlock bb , int i ) {
401+ ssaDefReachesReadWithinBlock ( v , def , bb , i )
409402 or
410- variableRead ( bb , i , v , rk ) and
403+ variableRead ( bb , i , v ) and
411404 ssaDefReachesEndOfBlock ( getABasicBlockPredecessor ( bb ) , def , v ) and
412- not ssaDefReachesReadWithinBlock ( v , _, bb , i , _ )
405+ not ssaDefReachesReadWithinBlock ( v , _, bb , i )
413406 }
414407
415408 /**
@@ -439,7 +432,7 @@ private module Cached {
439432 exists ( int rnk |
440433 rnk = ssaDefRank ( def , _, bb1 , i1 , _) and
441434 rnk + 1 = ssaDefRank ( def , _, bb1 , i2 , SsaRead ( ) ) and
442- variableRead ( bb1 , i2 , _, _ ) and
435+ variableRead ( bb1 , i2 , _) and
443436 bb2 = bb1
444437 )
445438 or
0 commit comments