Commit 929c2aa2 authored by Todd Neal's avatar Todd Neal Committed by Keith Randall

[dev.ssa] cmd/compile/ssa: fix unit tests

Fix out of bounds array panic due to CL 11238.

Change-Id: Id8a46f1ee20cb1f46775d0c04cc4944d729dfceb
Reviewed-on: https://go-review.googlesource.com/11540Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent 8c46aa54
...@@ -105,6 +105,9 @@ func checkFunc(f *Func) { ...@@ -105,6 +105,9 @@ func checkFunc(f *Func) {
} }
if v.Op == OpAddr { if v.Op == OpAddr {
if len(v.Args) == 0 {
f.Fatalf("no args for OpAddr %s", v.LongString())
}
if v.Args[0].Op != OpSP && v.Args[0].Op != OpSB { if v.Args[0].Op != OpSP && v.Args[0].Op != OpSB {
f.Fatalf("bad arg to OpAddr %v", v) f.Fatalf("bad arg to OpAddr %v", v)
} }
......
...@@ -14,9 +14,10 @@ func TestDeadStore(t *testing.T) { ...@@ -14,9 +14,10 @@ func TestDeadStore(t *testing.T) {
fun := Fun(c, "entry", fun := Fun(c, "entry",
Bloc("entry", Bloc("entry",
Valu("start", OpArg, TypeMem, 0, ".mem"), Valu("start", OpArg, TypeMem, 0, ".mem"),
Valu("sb", OpSB, TypeInvalid, 0, nil),
Valu("v", OpConst, TypeBool, 0, true), Valu("v", OpConst, TypeBool, 0, true),
Valu("addr1", OpAddr, ptrType, 0, nil), Valu("addr1", OpAddr, ptrType, 0, nil, "sb"),
Valu("addr2", OpAddr, ptrType, 0, nil), Valu("addr2", OpAddr, ptrType, 0, nil, "sb"),
Valu("store1", OpStore, TypeMem, 0, nil, "addr1", "v", "start"), Valu("store1", OpStore, TypeMem, 0, nil, "addr1", "v", "start"),
Valu("store2", OpStore, TypeMem, 0, nil, "addr2", "v", "store1"), Valu("store2", OpStore, TypeMem, 0, nil, "addr2", "v", "store1"),
Valu("store3", OpStore, TypeMem, 0, nil, "addr1", "v", "store2"), Valu("store3", OpStore, TypeMem, 0, nil, "addr1", "v", "store2"),
...@@ -40,8 +41,9 @@ func TestDeadStorePhi(t *testing.T) { ...@@ -40,8 +41,9 @@ func TestDeadStorePhi(t *testing.T) {
fun := Fun(c, "entry", fun := Fun(c, "entry",
Bloc("entry", Bloc("entry",
Valu("start", OpArg, TypeMem, 0, ".mem"), Valu("start", OpArg, TypeMem, 0, ".mem"),
Valu("sb", OpSB, TypeInvalid, 0, nil),
Valu("v", OpConst, TypeBool, 0, true), Valu("v", OpConst, TypeBool, 0, true),
Valu("addr", OpAddr, ptrType, 0, nil), Valu("addr", OpAddr, ptrType, 0, nil, "sb"),
Goto("loop")), Goto("loop")),
Bloc("loop", Bloc("loop",
Valu("phi", OpPhi, TypeMem, 0, nil, "start", "store"), Valu("phi", OpPhi, TypeMem, 0, nil, "start", "store"),
...@@ -66,9 +68,10 @@ func TestDeadStoreTypes(t *testing.T) { ...@@ -66,9 +68,10 @@ func TestDeadStoreTypes(t *testing.T) {
fun := Fun(c, "entry", fun := Fun(c, "entry",
Bloc("entry", Bloc("entry",
Valu("start", OpArg, TypeMem, 0, ".mem"), Valu("start", OpArg, TypeMem, 0, ".mem"),
Valu("sb", OpSB, TypeInvalid, 0, nil),
Valu("v", OpConst, TypeBool, 0, true), Valu("v", OpConst, TypeBool, 0, true),
Valu("addr1", OpAddr, t1, 0, nil), Valu("addr1", OpAddr, t1, 0, nil, "sb"),
Valu("addr2", OpAddr, t2, 0, nil), Valu("addr2", OpAddr, t2, 0, nil, "sb"),
Valu("store1", OpStore, TypeMem, 0, nil, "addr1", "v", "start"), Valu("store1", OpStore, TypeMem, 0, nil, "addr1", "v", "start"),
Valu("store2", OpStore, TypeMem, 0, nil, "addr2", "v", "store1"), Valu("store2", OpStore, TypeMem, 0, nil, "addr2", "v", "store1"),
Goto("exit")), Goto("exit")),
......
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