@@ -51,16 +51,6 @@ private newtype TDefOrUse =
51
51
TExplicitUse ( Operand op ) { isExplicitUse ( op ) } or
52
52
TReturnParamIndirection ( Operand op ) { returnParameterIndirection ( op , _) }
53
53
54
- pragma [ nomagic]
55
- private int getRank ( DefOrUse defOrUse , IRBlock block ) {
56
- defOrUse =
57
- rank [ result ] ( int i , DefOrUse cand |
58
- block .getInstruction ( i ) = toInstruction ( cand )
59
- |
60
- cand order by i
61
- )
62
- }
63
-
64
54
private class DefOrUse extends TDefOrUse {
65
55
/** Gets the instruction associated with this definition, if any. */
66
56
Instruction asDef ( ) { none ( ) }
@@ -74,9 +64,10 @@ private class DefOrUse extends TDefOrUse {
74
64
/** Gets the block of this definition or use. */
75
65
abstract IRBlock getBlock ( ) ;
76
66
77
- /** Holds if this definition or use has rank `rank` in block `block`. */
78
- cached
79
- final predicate hasRankInBlock ( IRBlock block , int rnk ) { rnk = getRank ( this , block ) }
67
+ /** Holds if this definition or use has index `index` in block `block`. */
68
+ final predicate hasIndexInBlock ( IRBlock block , int index ) {
69
+ block .getInstruction ( index ) = toInstruction ( this )
70
+ }
80
71
81
72
/** Gets the location of this element. */
82
73
abstract Cpp:: Location getLocation ( ) ;
@@ -313,8 +304,8 @@ cached
313
304
private module Cached {
314
305
private predicate defUseFlow ( Node nodeFrom , Node nodeTo ) {
315
306
exists ( IRBlock bb1 , int i1 , IRBlock bb2 , int i2 , DefOrUse defOrUse , Use use |
316
- defOrUse .hasRankInBlock ( bb1 , i1 ) and
317
- use .hasRankInBlock ( bb2 , i2 ) and
307
+ defOrUse .hasIndexInBlock ( bb1 , i1 ) and
308
+ use .hasIndexInBlock ( bb2 , i2 ) and
318
309
adjacentDefRead ( _, bb1 , i1 , bb2 , i2 ) and
319
310
nodeFrom .asInstruction ( ) = toInstruction ( defOrUse ) and
320
311
flowOutOfAddressStep ( use .getOperand ( ) , nodeTo )
@@ -326,9 +317,9 @@ private module Cached {
326
317
exists ( IRBlock bb1 , int i1 , IRBlock bb2 , int i2 , Def def , Use use |
327
318
nodeFrom .isTerminal ( ) and
328
319
def .getInstruction ( ) = nodeFrom .getStoreInstruction ( ) and
329
- def .hasRankInBlock ( bb1 , i1 ) and
320
+ def .hasIndexInBlock ( bb1 , i1 ) and
330
321
adjacentDefRead ( _, bb1 , i1 , bb2 , i2 ) and
331
- use .hasRankInBlock ( bb2 , i2 ) and
322
+ use .hasIndexInBlock ( bb2 , i2 ) and
332
323
flowOutOfAddressStep ( use .getOperand ( ) , nodeTo )
333
324
)
334
325
or
@@ -359,8 +350,8 @@ private module Cached {
359
350
360
351
private predicate fromReadNode ( ReadNode nodeFrom , Node nodeTo ) {
361
352
exists ( IRBlock bb1 , int i1 , IRBlock bb2 , int i2 , Use use1 , Use use2 |
362
- use1 .hasRankInBlock ( bb1 , i1 ) and
363
- use2 .hasRankInBlock ( bb2 , i2 ) and
353
+ use1 .hasIndexInBlock ( bb1 , i1 ) and
354
+ use2 .hasIndexInBlock ( bb2 , i2 ) and
364
355
use1 .getOperand ( ) .getDef ( ) = nodeFrom .getInstruction ( ) and
365
356
adjacentDefRead ( _, bb1 , i1 , bb2 , i2 ) and
366
357
flowOutOfAddressStep ( use2 .getOperand ( ) , nodeTo )
@@ -371,15 +362,15 @@ private module Cached {
371
362
exists ( PhiNode phi , Use use , IRBlock block , int rnk |
372
363
phi = nodeFrom .getPhiNode ( ) and
373
364
adjacentDefRead ( phi , _, _, block , rnk ) and
374
- use .hasRankInBlock ( block , rnk ) and
365
+ use .hasIndexInBlock ( block , rnk ) and
375
366
flowOutOfAddressStep ( use .getOperand ( ) , nodeTo )
376
367
)
377
368
}
378
369
379
370
private predicate toPhiNode ( Node nodeFrom , SsaPhiNode nodeTo ) {
380
371
// Flow to phi nodes
381
372
exists ( Def def , IRBlock block , int rnk |
382
- def .hasRankInBlock ( block , rnk ) and
373
+ def .hasIndexInBlock ( block , rnk ) and
383
374
nodeTo .hasInputAtRankInBlock ( block , rnk )
384
375
|
385
376
exists ( StoreNodeInstr storeNode |
@@ -512,8 +503,8 @@ private module Cached {
512
503
|
513
504
store = def .getInstruction ( ) and
514
505
store .getSourceValueOperand ( ) = operand and
515
- def .hasRankInBlock ( block1 , rnk1 ) and
516
- use .hasRankInBlock ( block2 , rnk2 ) and
506
+ def .hasIndexInBlock ( block1 , rnk1 ) and
507
+ use .hasIndexInBlock ( block2 , rnk2 ) and
517
508
adjacentDefRead ( _, block1 , rnk1 , block2 , rnk2 )
518
509
|
519
510
// The shared SSA library has determined that `use` is the next use of the operand
@@ -543,12 +534,12 @@ private module Cached {
543
534
not operand = getSourceAddressOperand ( _) and
544
535
exists ( Use use1 , Use use2 , IRBlock block1 , int rnk1 , IRBlock block2 , int rnk2 |
545
536
use1 .getOperand ( ) = operand and
546
- use1 .hasRankInBlock ( block1 , rnk1 ) and
537
+ use1 .hasIndexInBlock ( block1 , rnk1 ) and
547
538
// Don't flow to the next use if this use is part of a store operation that totally
548
539
// overrides a variable.
549
540
not explicitWrite ( true , _, use1 .getOperand ( ) .getDef ( ) ) and
550
541
adjacentDefRead ( _, block1 , rnk1 , block2 , rnk2 ) and
551
- use2 .hasRankInBlock ( block2 , rnk2 ) and
542
+ use2 .hasIndexInBlock ( block2 , rnk2 ) and
552
543
flowOutOfAddressStep ( use2 .getOperand ( ) , nodeTo )
553
544
)
554
545
or
@@ -620,7 +611,7 @@ import Cached
620
611
predicate variableWrite ( IRBlock bb , int i , SourceVariable v , boolean certain ) {
621
612
DataFlowImplCommon:: forceCachingInSameStage ( ) and
622
613
exists ( Def def |
623
- def .hasRankInBlock ( bb , i ) and
614
+ def .hasIndexInBlock ( bb , i ) and
624
615
v = def .getSourceVariable ( ) and
625
616
( if def .isCertain ( ) then certain = true else certain = false )
626
617
)
@@ -632,7 +623,7 @@ predicate variableWrite(IRBlock bb, int i, SourceVariable v, boolean certain) {
632
623
*/
633
624
predicate variableRead ( IRBlock bb , int i , SourceVariable v , boolean certain ) {
634
625
exists ( Use use |
635
- use .hasRankInBlock ( bb , i ) and
626
+ use .hasIndexInBlock ( bb , i ) and
636
627
v = use .getSourceVariable ( ) and
637
628
certain = true
638
629
)
0 commit comments