]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: enforce that all phis are first during regalloc
authorJosh Bleecher Snyder <josharian@gmail.com>
Wed, 5 Aug 2015 18:01:59 +0000 (11:01 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 6 Aug 2015 17:26:43 +0000 (17:26 +0000)
Change-Id: I035708f5d0659b3deef00808d35e1cc8a80215e0
Reviewed-on: https://go-review.googlesource.com/13243
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/regalloc.go

index 9056531634f1b53a9e4e5de8f6e928345c69ca78..b8a2f24c3314729a5d032c60e45e0cd3dd2c7eea 100644 (file)
@@ -394,11 +394,16 @@ func regalloc(f *Func) {
 // immediately preceding the phi's block.
 func addPhiCopies(f *Func) {
        for _, b := range f.Blocks {
+               phis := true // all phis should appear first; confirm that as we go
                for _, v := range b.Values {
-                       if v.Op != OpPhi {
-                               break // all phis should appear first
-                       }
-                       if v.Type.IsMemory() { // TODO: only "regallocable" types
+                       switch {
+                       case v.Op == OpPhi && !phis:
+                               f.Fatalf("phi var %v not at beginning of block %v:\n%s\n", v, v.Block, f)
+                               break
+                       case v.Op != OpPhi:
+                               phis = false
+                               continue
+                       case v.Type.IsMemory(): // TODO: only "regallocable" types
                                continue
                        }
                        for i, w := range v.Args {