]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: check that SSA memory args are in the right place
authorJosh Bleecher Snyder <josharian@gmail.com>
Wed, 4 May 2016 18:43:42 +0000 (11:43 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Wed, 4 May 2016 19:54:44 +0000 (19:54 +0000)
Fixes #15510

Change-Id: I2e0568778ef90cf29712753b8c42109ef84a0256
Reviewed-on: https://go-review.googlesource.com/22784
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/check.go

index 457bf639db7f2634386237c249495f9bc9b95bf3..d77b912041554a0c1df97e743e88651479ddd2e5 100644 (file)
@@ -208,10 +208,16 @@ func checkFunc(f *Func) {
                                f.Fatalf("value %s has an AuxInt value %d but shouldn't", v.LongString(), v.AuxInt)
                        }
 
-                       for _, arg := range v.Args {
+                       for i, arg := range v.Args {
                                if arg == nil {
                                        f.Fatalf("value %s has nil arg", v.LongString())
                                }
+                               if v.Op != OpPhi {
+                                       // For non-Phi ops, memory args must be last, if present
+                                       if arg.Type.IsMemory() && i != len(v.Args)-1 {
+                                               f.Fatalf("value %s has non-final memory arg (%d < %d)", v.LongString(), i, len(v.Args)-1)
+                                       }
+                               }
                        }
 
                        if valueMark[v.ID] {