@@ -45,7 +45,7 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
45
45
/** An SSA Phi definition, whose sign is the union of the signs of its inputs. */
46
46
private class PhiSignDef extends FlowSignDef instanceof SemSsaPhiNode {
47
47
final override Sign getSign ( ) {
48
- exists ( SemSsaVariable inp , SemSsaReadPositionPhiInputEdge edge |
48
+ exists ( SemSsaVariable inp , SsaReadPositionPhiInputEdge edge |
49
49
edge .phiInput ( this , inp ) and
50
50
result = semSsaSign ( inp , edge )
51
51
)
@@ -170,11 +170,11 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
170
170
override Sign getSignRestriction ( ) {
171
171
// Propagate via SSA
172
172
// Propagate the sign from the def of `v`, incorporating any inference from guards.
173
- result = semSsaSign ( v , any ( SemSsaReadPositionBlock bb | bb .getAnExpr ( ) = this ) )
173
+ result = semSsaSign ( v , any ( SsaReadPositionBlock bb | bb . getBlock ( ) .getAnExpr ( ) = this ) )
174
174
or
175
175
// No block for this read. Just use the sign of the def.
176
176
// REVIEW: How can this happen?
177
- not exists ( SemSsaReadPositionBlock bb | bb .getAnExpr ( ) = this ) and
177
+ not exists ( SsaReadPositionBlock bb | bb . getBlock ( ) .getAnExpr ( ) = this ) and
178
178
result = semSsaDefSign ( v )
179
179
}
180
180
}
@@ -290,7 +290,7 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
290
290
* to only include bounds for which we might determine a sign.
291
291
*/
292
292
private predicate lowerBound (
293
- SemExpr lowerbound , SemSsaVariable v , SemSsaReadPosition pos , boolean isStrict
293
+ SemExpr lowerbound , SemSsaVariable v , SsaReadPosition pos , boolean isStrict
294
294
) {
295
295
exists ( boolean testIsTrue , SemRelationalExpr comp |
296
296
pos .hasReadOfVar ( v ) and
@@ -314,7 +314,7 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
314
314
* to only include bounds for which we might determine a sign.
315
315
*/
316
316
private predicate upperBound (
317
- SemExpr upperbound , SemSsaVariable v , SemSsaReadPosition pos , boolean isStrict
317
+ SemExpr upperbound , SemSsaVariable v , SsaReadPosition pos , boolean isStrict
318
318
) {
319
319
exists ( boolean testIsTrue , SemRelationalExpr comp |
320
320
pos .hasReadOfVar ( v ) and
@@ -340,7 +340,7 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
340
340
* - `isEq = true` : `v = eqbound`
341
341
* - `isEq = false` : `v != eqbound`
342
342
*/
343
- private predicate eqBound ( SemExpr eqbound , SemSsaVariable v , SemSsaReadPosition pos , boolean isEq ) {
343
+ private predicate eqBound ( SemExpr eqbound , SemSsaVariable v , SsaReadPosition pos , boolean isEq ) {
344
344
exists ( SemGuard guard , boolean testIsTrue , boolean polarity , SemExpr e |
345
345
pos .hasReadOfVar ( pragma [ only_bind_into ] ( v ) ) and
346
346
guardControlsSsaRead ( guard , pragma [ only_bind_into ] ( pos ) , testIsTrue ) and
@@ -355,7 +355,7 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
355
355
* Holds if `bound` is a bound for `v` at `pos` that needs to be positive in
356
356
* order for `v` to be positive.
357
357
*/
358
- private predicate posBound ( SemExpr bound , SemSsaVariable v , SemSsaReadPosition pos ) {
358
+ private predicate posBound ( SemExpr bound , SemSsaVariable v , SsaReadPosition pos ) {
359
359
upperBound ( bound , v , pos , _) or
360
360
eqBound ( bound , v , pos , true )
361
361
}
@@ -364,7 +364,7 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
364
364
* Holds if `bound` is a bound for `v` at `pos` that needs to be negative in
365
365
* order for `v` to be negative.
366
366
*/
367
- private predicate negBound ( SemExpr bound , SemSsaVariable v , SemSsaReadPosition pos ) {
367
+ private predicate negBound ( SemExpr bound , SemSsaVariable v , SsaReadPosition pos ) {
368
368
lowerBound ( bound , v , pos , _) or
369
369
eqBound ( bound , v , pos , true )
370
370
}
@@ -373,24 +373,24 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
373
373
* Holds if `bound` is a bound for `v` at `pos` that can restrict whether `v`
374
374
* can be zero.
375
375
*/
376
- private predicate zeroBound ( SemExpr bound , SemSsaVariable v , SemSsaReadPosition pos ) {
376
+ private predicate zeroBound ( SemExpr bound , SemSsaVariable v , SsaReadPosition pos ) {
377
377
lowerBound ( bound , v , pos , _) or
378
378
upperBound ( bound , v , pos , _) or
379
379
eqBound ( bound , v , pos , _)
380
380
}
381
381
382
382
/** Holds if `bound` allows `v` to be positive at `pos`. */
383
- private predicate posBoundOk ( SemExpr bound , SemSsaVariable v , SemSsaReadPosition pos ) {
383
+ private predicate posBoundOk ( SemExpr bound , SemSsaVariable v , SsaReadPosition pos ) {
384
384
posBound ( bound , v , pos ) and TPos ( ) = semExprSign ( bound )
385
385
}
386
386
387
387
/** Holds if `bound` allows `v` to be negative at `pos`. */
388
- private predicate negBoundOk ( SemExpr bound , SemSsaVariable v , SemSsaReadPosition pos ) {
388
+ private predicate negBoundOk ( SemExpr bound , SemSsaVariable v , SsaReadPosition pos ) {
389
389
negBound ( bound , v , pos ) and TNeg ( ) = semExprSign ( bound )
390
390
}
391
391
392
392
/** Holds if `bound` allows `v` to be zero at `pos`. */
393
- private predicate zeroBoundOk ( SemExpr bound , SemSsaVariable v , SemSsaReadPosition pos ) {
393
+ private predicate zeroBoundOk ( SemExpr bound , SemSsaVariable v , SsaReadPosition pos ) {
394
394
lowerBound ( bound , v , pos , _) and TNeg ( ) = semExprSign ( bound )
395
395
or
396
396
lowerBound ( bound , v , pos , false ) and TZero ( ) = semExprSign ( bound )
@@ -408,7 +408,7 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
408
408
* Holds if there is a bound that might restrict whether `v` has the sign `s`
409
409
* at `pos`.
410
410
*/
411
- private predicate hasGuard ( SemSsaVariable v , SemSsaReadPosition pos , Sign s ) {
411
+ private predicate hasGuard ( SemSsaVariable v , SsaReadPosition pos , Sign s ) {
412
412
s = TPos ( ) and posBound ( _, v , pos )
413
413
or
414
414
s = TNeg ( ) and negBound ( _, v , pos )
@@ -421,7 +421,7 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
421
421
* might be ruled out by a guard.
422
422
*/
423
423
pragma [ noinline]
424
- private Sign guardedSsaSign ( SemSsaVariable v , SemSsaReadPosition pos ) {
424
+ private Sign guardedSsaSign ( SemSsaVariable v , SsaReadPosition pos ) {
425
425
result = semSsaDefSign ( v ) and
426
426
pos .hasReadOfVar ( v ) and
427
427
hasGuard ( v , pos , result )
@@ -432,7 +432,7 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
432
432
* can rule it out.
433
433
*/
434
434
pragma [ noinline]
435
- private Sign unguardedSsaSign ( SemSsaVariable v , SemSsaReadPosition pos ) {
435
+ private Sign unguardedSsaSign ( SemSsaVariable v , SsaReadPosition pos ) {
436
436
result = semSsaDefSign ( v ) and
437
437
pos .hasReadOfVar ( v ) and
438
438
not hasGuard ( v , pos , result )
@@ -443,7 +443,7 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
443
443
* ruled out the sign but does not.
444
444
* This does not check that the definition of `v` also allows the sign.
445
445
*/
446
- private Sign guardedSsaSignOk ( SemSsaVariable v , SemSsaReadPosition pos ) {
446
+ private Sign guardedSsaSignOk ( SemSsaVariable v , SsaReadPosition pos ) {
447
447
result = TPos ( ) and
448
448
forex ( SemExpr bound | posBound ( bound , v , pos ) | posBoundOk ( bound , v , pos ) )
449
449
or
@@ -455,7 +455,7 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
455
455
}
456
456
457
457
/** Gets a possible sign for `v` at `pos`. */
458
- private Sign semSsaSign ( SemSsaVariable v , SemSsaReadPosition pos ) {
458
+ private Sign semSsaSign ( SemSsaVariable v , SsaReadPosition pos ) {
459
459
result = unguardedSsaSign ( v , pos )
460
460
or
461
461
result = guardedSsaSign ( v , pos ) and
0 commit comments