]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: make sure entry block has no predecessors
authorKeith Randall <khr@golang.org>
Wed, 12 Aug 2015 21:51:24 +0000 (14:51 -0700)
committerKeith Randall <khr@golang.org>
Wed, 12 Aug 2015 22:27:15 +0000 (22:27 +0000)
Fix one test that build a violating CFG.

Change-Id: Ie0296ced602984d914a70461c76559c507ce2510
Reviewed-on: https://go-review.googlesource.com/13621
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/compile/internal/ssa/check.go
src/cmd/compile/internal/ssa/dom_test.go

index dfb33dbd079aee24bc55e2150ebd862ab91b9bdf..263140113050dfb9c0a3edf3111103e119abf63b 100644 (file)
@@ -157,6 +157,10 @@ func checkFunc(f *Func) {
                }
        }
 
+       if len(f.Entry.Preds) > 0 {
+               f.Fatalf("entry block %s of %s has predecessor(s) %v", f.Entry, f.Name, f.Entry.Preds)
+       }
+
        // Check to make sure all Values referenced are in the function.
        for _, b := range f.Blocks {
                for _, v := range b.Values {
index 6cd2ff440c9f2a539dce61e00782940ee26c00f4..e1259079297589e02b7156a699928759e43b0c8b 100644 (file)
@@ -317,11 +317,13 @@ func TestDominatorsMultPredRev(t *testing.T) {
        c := testConfig(t)
        fun := Fun(c, "entry",
                Bloc("entry",
+                       Goto("first")),
+               Bloc("first",
                        Valu("mem", OpArg, TypeMem, 0, ".mem"),
                        Valu("p", OpConstBool, TypeBool, 0, true),
                        Goto("a")),
                Bloc("a",
-                       If("p", "b", "entry")),
+                       If("p", "b", "first")),
                Bloc("b",
                        Goto("c")),
                Bloc("c",
@@ -330,10 +332,11 @@ func TestDominatorsMultPredRev(t *testing.T) {
                        Exit("mem")))
 
        doms := map[string]string{
-               "a":    "entry",
-               "b":    "a",
-               "c":    "b",
-               "exit": "c",
+               "first": "entry",
+               "a":     "first",
+               "b":     "a",
+               "c":     "b",
+               "exit":  "c",
        }
 
        CheckFunc(fun.f)