Commit a027466e authored by Keith Randall's avatar Keith Randall

cmd/compile: check that phis are always first after scheduling

Update #20178

Change-Id: I603f77268ed38afdd84228c775efe006f08f14a7
Reviewed-on: https://go-review.googlesource.com/45018
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
parent f425f549
......@@ -444,6 +444,22 @@ func memCheck(f *Func) {
}
}
}
// Check that after scheduling, phis are always first in the block.
if f.scheduled {
for _, b := range f.Blocks {
seenNonPhi := false
for _, v := range b.Values {
if v.Op == OpPhi {
if seenNonPhi {
f.Fatalf("phi after non-phi @ %s: %s", b, v)
}
} else {
seenNonPhi = true
}
}
}
}
}
// domCheck reports whether x dominates y (including x==y).
......
......@@ -117,7 +117,11 @@ func dse(f *Func) {
}
// walk to previous store
if v.Op == OpPhi {
continue // At start of block. Move on to next block.
// At start of block. Move on to next block.
// The memory phi, if it exists, is always
// the first logical store in the block.
// (Even if it isn't the first in the current b.Values order.)
continue
}
for _, a := range v.Args {
if a.Block == b && a.Type.IsMemory() {
......
......@@ -211,6 +211,8 @@ search:
}
if v.Op == OpPhi {
// A Phi implies we have reached the top of the block.
// The memory phi, if it exists, is always
// the first logical store in the block.
continue search
}
if v.Type.IsTuple() && v.Type.FieldType(1).IsMemory() {
......@@ -228,6 +230,8 @@ search:
const limit = 50
for i := 0; i < limit; i++ {
if m.Op == OpPhi {
// The memory phi, if it exists, is always
// the first logical store in the block.
break
}
if m.Block.ID != target.Block.ID {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment