File tree 3 files changed +25
-1
lines changed
src/cmd/compile/internal/ssa 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -444,6 +444,22 @@ func memCheck(f *Func) {
444
444
}
445
445
}
446
446
}
447
+
448
+ // Check that after scheduling, phis are always first in the block.
449
+ if f .scheduled {
450
+ for _ , b := range f .Blocks {
451
+ seenNonPhi := false
452
+ for _ , v := range b .Values {
453
+ if v .Op == OpPhi {
454
+ if seenNonPhi {
455
+ f .Fatalf ("phi after non-phi @ %s: %s" , b , v )
456
+ }
457
+ } else {
458
+ seenNonPhi = true
459
+ }
460
+ }
461
+ }
462
+ }
447
463
}
448
464
449
465
// domCheck reports whether x dominates y (including x==y).
Original file line number Diff line number Diff line change @@ -117,7 +117,11 @@ func dse(f *Func) {
117
117
}
118
118
// walk to previous store
119
119
if v .Op == OpPhi {
120
- continue // At start of block. Move on to next block.
120
+ // At start of block. Move on to next block.
121
+ // The memory phi, if it exists, is always
122
+ // the first logical store in the block.
123
+ // (Even if it isn't the first in the current b.Values order.)
124
+ continue
121
125
}
122
126
for _ , a := range v .Args {
123
127
if a .Block == b && a .Type .IsMemory () {
Original file line number Diff line number Diff line change @@ -211,6 +211,8 @@ search:
211
211
}
212
212
if v .Op == OpPhi {
213
213
// A Phi implies we have reached the top of the block.
214
+ // The memory phi, if it exists, is always
215
+ // the first logical store in the block.
214
216
continue search
215
217
}
216
218
if v .Type .IsTuple () && v .Type .FieldType (1 ).IsMemory () {
@@ -228,6 +230,8 @@ search:
228
230
const limit = 50
229
231
for i := 0 ; i < limit ; i ++ {
230
232
if m .Op == OpPhi {
233
+ // The memory phi, if it exists, is always
234
+ // the first logical store in the block.
231
235
break
232
236
}
233
237
if m .Block .ID != target .Block .ID {
You can’t perform that action at this time.
0 commit comments