]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/ssa: add Op{SP,SB} type checks to check.go
authorisharipo <iskander.sharipov@intel.com>
Thu, 12 Apr 2018 17:54:36 +0000 (20:54 +0300)
committerIlya Tocar <ilya.tocar@intel.com>
Tue, 24 Apr 2018 15:51:15 +0000 (15:51 +0000)
gc/ssa.go initilizes SP and SB values with TUINTPTR type.
Assign same type in SSA tests and modify check.go to catch
mismatching types for those ops.

This makes SSA tests more consistent.

Change-Id: I798440d57d00fb949d1a0cd796759c9b82a934bd
Reviewed-on: https://go-review.googlesource.com/106658
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/branchelim_test.go
src/cmd/compile/internal/ssa/check.go
src/cmd/compile/internal/ssa/cse_test.go
src/cmd/compile/internal/ssa/deadstore_test.go
src/cmd/compile/internal/ssa/fuse_test.go
src/cmd/compile/internal/ssa/loop_test.go
src/cmd/compile/internal/ssa/nilcheck_test.go
src/cmd/compile/internal/ssa/passbm_test.go
src/cmd/compile/internal/ssa/shift_test.go
src/cmd/compile/internal/ssa/writebarrier_test.go

index 30bb133f8ed7a5c27d1c1460048cd0361e6fe0a0..20fa84d63ae53ba252d8eee10fd58bc2847545a0 100644 (file)
@@ -37,7 +37,7 @@ func TestBranchElimIf(t *testing.T) {
                        fun := c.Fun("entry",
                                Bloc("entry",
                                        Valu("start", OpInitMem, types.TypeMem, 0, nil),
-                                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                                        Valu("const1", OpConst32, intType, 1, nil),
                                        Valu("const2", OpConst32, intType, 2, nil),
                                        Valu("addr", OpAddr, boolType.PtrTo(), 0, nil, "sb"),
@@ -89,7 +89,7 @@ func TestBranchElimIfElse(t *testing.T) {
                        fun := c.Fun("entry",
                                Bloc("entry",
                                        Valu("start", OpInitMem, types.TypeMem, 0, nil),
-                                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                                        Valu("const1", OpConst32, intType, 1, nil),
                                        Valu("const2", OpConst32, intType, 2, nil),
                                        Valu("addr", OpAddr, boolType.PtrTo(), 0, nil, "sb"),
@@ -141,7 +141,7 @@ func TestNoBranchElimLoop(t *testing.T) {
                        fun := c.Fun("entry",
                                Bloc("entry",
                                        Valu("start", OpInitMem, types.TypeMem, 0, nil),
-                                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                                        Valu("const2", OpConst32, intType, 2, nil),
                                        Valu("const3", OpConst32, intType, 3, nil),
                                        Goto("b5")),
index faa0ba5d6254fdb34997bb552fe45924bd3a81be..a0ef5fbced5d329f703e1ac05dc5879f4ad32239 100644 (file)
@@ -212,8 +212,17 @@ func checkFunc(f *Func) {
                                f.Fatalf("unexpected floating-point type %v", v.LongString())
                        }
 
+                       // Check types.
+                       // TODO: more type checks?
+                       switch c := f.Config; v.Op {
+                       case OpSP, OpSB:
+                               if v.Type != c.Types.Uintptr {
+                                       f.Fatalf("bad %s type: want uintptr, have %s",
+                                               v.Op, v.Type.String())
+                               }
+                       }
+
                        // TODO: check for cycles in values
-                       // TODO: check type
                }
        }
 
index aab50eb7d45b06b7fd4db56611b607126480569a..adb8664945dbb24bb28de093aa48a48dcd474055 100644 (file)
@@ -25,7 +25,7 @@ func TestCSEAuxPartitionBug(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sp", OpSP, c.config.Types.BytePtr, 0, nil),
+                       Valu("sp", OpSP, c.config.Types.Uintptr, 0, nil),
                        Valu("r7", OpAdd64, c.config.Types.Int64, 0, nil, "arg3", "arg1"),
                        Valu("r1", OpAdd64, c.config.Types.Int64, 0, nil, "arg1", "arg2"),
                        Valu("arg1", OpArg, c.config.Types.Int64, 0, arg1Aux),
@@ -93,9 +93,9 @@ func TestZCSE(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sp", OpSP, c.config.Types.BytePtr, 0, nil),
-                       Valu("sb1", OpSB, c.config.Types.BytePtr, 0, nil),
-                       Valu("sb2", OpSB, c.config.Types.BytePtr, 0, nil),
+                       Valu("sp", OpSP, c.config.Types.Uintptr, 0, nil),
+                       Valu("sb1", OpSB, c.config.Types.Uintptr, 0, nil),
+                       Valu("sb2", OpSB, c.config.Types.Uintptr, 0, nil),
                        Valu("addr1", OpAddr, c.config.Types.Int64.PtrTo(), 0, nil, "sb1"),
                        Valu("addr2", OpAddr, c.config.Types.Int64.PtrTo(), 0, nil, "sb2"),
                        Valu("a1ld", OpLoad, c.config.Types.Int64, 0, nil, "addr1", "start"),
index 2326c6c413afa7f119132d574be07256aa755ccd..33cb4b97553c0513b785a7b5cb73507901b7c402 100644 (file)
@@ -16,7 +16,7 @@ func TestDeadStore(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Valu("v", OpConstBool, c.config.Types.Bool, 1, nil),
                        Valu("addr1", OpAddr, ptrType, 0, nil, "sb"),
                        Valu("addr2", OpAddr, ptrType, 0, nil, "sb"),
@@ -51,7 +51,7 @@ func TestDeadStorePhi(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Valu("v", OpConstBool, c.config.Types.Bool, 1, nil),
                        Valu("addr", OpAddr, ptrType, 0, nil, "sb"),
                        Goto("loop")),
@@ -78,7 +78,7 @@ func TestDeadStoreTypes(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Valu("v", OpConstBool, c.config.Types.Bool, 1, nil),
                        Valu("addr1", OpAddr, t1, 0, nil, "sb"),
                        Valu("addr2", OpAddr, t2, 0, nil, "sb"),
@@ -108,7 +108,7 @@ func TestDeadStoreUnsafe(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Valu("v", OpConstBool, c.config.Types.Bool, 1, nil),
                        Valu("addr1", OpAddr, ptrType, 0, nil, "sb"),
                        Valu("store1", OpStore, types.TypeMem, 0, c.config.Types.Int64, "addr1", "v", "start"), // store 8 bytes
index beae15af48a5aa3b8b596a6cca5f341d9922079f..bba92f805ea7160362f746c301239e91ef8d32ef 100644 (file)
@@ -13,7 +13,7 @@ func TestFuseEliminatesOneBranch(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Goto("checkPtr")),
                Bloc("checkPtr",
                        Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"),
@@ -41,7 +41,7 @@ func TestFuseEliminatesBothBranches(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Goto("checkPtr")),
                Bloc("checkPtr",
                        Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"),
@@ -74,7 +74,7 @@ func TestFuseHandlesPhis(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Goto("checkPtr")),
                Bloc("checkPtr",
                        Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"),
@@ -107,7 +107,7 @@ func TestFuseEliminatesEmptyBlocks(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Goto("z0")),
                Bloc("z1",
                        Goto("z2")),
index f8dcdb0132df0610104dea5ad1fb3e1f5343c443..6810f5f797f78c99e580caea6de93b2251fc6f53 100644 (file)
@@ -49,7 +49,7 @@ func TestLoopConditionS390X(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("SP", OpSP, c.config.Types.UInt64, 0, nil),
+                       Valu("SP", OpSP, c.config.Types.Uintptr, 0, nil),
                        Valu("ret", OpAddr, c.config.Types.Int64.PtrTo(), 0, nil, "SP"),
                        Valu("N", OpArg, c.config.Types.Int64, 0, c.Frontend().Auto(src.NoXPos, c.config.Types.Int64)),
                        Valu("starti", OpConst64, c.config.Types.Int64, 0, nil),
index 1d9e5d163016afa0e10b32052f094830cd04ad2f..3ca033797d7db451299fd87fca3baf5c7badb6a9 100644 (file)
@@ -24,7 +24,7 @@ func benchmarkNilCheckDeep(b *testing.B, depth int) {
        blocs = append(blocs,
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Goto(blockn(0)),
                ),
        )
@@ -69,7 +69,7 @@ func TestNilcheckSimple(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Goto("checkPtr")),
                Bloc("checkPtr",
                        Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"),
@@ -106,7 +106,7 @@ func TestNilcheckDomOrder(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Goto("checkPtr")),
                Bloc("checkPtr",
                        Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"),
@@ -142,7 +142,7 @@ func TestNilcheckAddr(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Goto("checkPtr")),
                Bloc("checkPtr",
                        Valu("ptr1", OpAddr, ptrType, 0, nil, "sb"),
@@ -175,7 +175,7 @@ func TestNilcheckAddPtr(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Goto("checkPtr")),
                Bloc("checkPtr",
                        Valu("off", OpConst64, c.config.Types.Int64, 20, nil),
@@ -210,8 +210,8 @@ func TestNilcheckPhi(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
-                       Valu("sp", OpSP, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
+                       Valu("sp", OpSP, c.config.Types.Uintptr, 0, nil),
                        Valu("baddr", OpAddr, c.config.Types.Bool, 0, "b", "sp"),
                        Valu("bool1", OpLoad, c.config.Types.Bool, 0, nil, "baddr", "mem"),
                        If("bool1", "b1", "b2")),
@@ -254,7 +254,7 @@ func TestNilcheckKeepRemove(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Goto("checkPtr")),
                Bloc("checkPtr",
                        Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"),
@@ -302,7 +302,7 @@ func TestNilcheckInFalseBranch(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Goto("checkPtr")),
                Bloc("checkPtr",
                        Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"),
@@ -353,7 +353,7 @@ func TestNilcheckUser(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Goto("checkPtr")),
                Bloc("checkPtr",
                        Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"),
@@ -392,7 +392,7 @@ func TestNilcheckBug(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
                        Goto("checkPtr")),
                Bloc("checkPtr",
                        Valu("ptr1", OpLoad, ptrType, 0, nil, "sb", "mem"),
index 5e0a7eb3bbd9efc9f29ad8467d094009748b728f..eefdbb87224e785cdb366743d34530eeca511fd6 100644 (file)
@@ -68,7 +68,7 @@ func genFunction(size int) []bloc {
        blocs = append(blocs,
                Bloc("entry",
                        Valu(valn("store", 0, 4), OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, types.Types[types.TUINTPTR], 0, nil),
                        Goto(blockn(1)),
                ),
        )
index ffb5a5947ec75aca3512ad451576df0cea7d0d14..3876d8df12c2642e6a0b2eebba0f91e317b0fd52 100644 (file)
@@ -35,7 +35,7 @@ func makeConstShiftFunc(c *Conf, amount int64, op Op, typ *types.Type) fun {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("SP", OpSP, c.config.Types.UInt64, 0, nil),
+                       Valu("SP", OpSP, c.config.Types.Uintptr, 0, nil),
                        Valu("argptr", OpOffPtr, ptyp, 8, nil, "SP"),
                        Valu("resptr", OpOffPtr, ptyp, 16, nil, "SP"),
                        Valu("load", OpLoad, typ, 0, nil, "argptr", "mem"),
@@ -93,7 +93,7 @@ func makeShiftExtensionFunc(c *Conf, amount int64, lshift, rshift Op, typ *types
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("mem", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("SP", OpSP, c.config.Types.UInt64, 0, nil),
+                       Valu("SP", OpSP, c.config.Types.Uintptr, 0, nil),
                        Valu("argptr", OpOffPtr, ptyp, 8, nil, "SP"),
                        Valu("resptr", OpOffPtr, ptyp, 16, nil, "SP"),
                        Valu("load", OpLoad, typ, 0, nil, "argptr", "mem"),
index c1f9ec7fc157958b5dd9ca1e2189f8012a86909d..0b11afc84da6433863765d6ea106fa764e872b88 100644 (file)
@@ -16,8 +16,8 @@ func TestWriteBarrierStoreOrder(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
-                       Valu("sp", OpSP, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
+                       Valu("sp", OpSP, c.config.Types.Uintptr, 0, nil),
                        Valu("v", OpConstNil, ptrType, 0, nil),
                        Valu("addr1", OpAddr, ptrType, 0, nil, "sb"),
                        Valu("wb2", OpStore, types.TypeMem, 0, ptrType, "addr1", "v", "wb1"),
@@ -40,8 +40,8 @@ func TestWriteBarrierPhi(t *testing.T) {
        fun := c.Fun("entry",
                Bloc("entry",
                        Valu("start", OpInitMem, types.TypeMem, 0, nil),
-                       Valu("sb", OpSB, types.TypeInvalid, 0, nil),
-                       Valu("sp", OpSP, types.TypeInvalid, 0, nil),
+                       Valu("sb", OpSB, c.config.Types.Uintptr, 0, nil),
+                       Valu("sp", OpSP, c.config.Types.Uintptr, 0, nil),
                        Goto("loop")),
                Bloc("loop",
                        Valu("phi", OpPhi, types.TypeMem, 0, nil, "start", "wb"),