1
0
mirror of https://github.com/golang/go synced 2024-10-05 16:41:21 -06:00

[dev.ssa] cmd/compile: make sure entry block has no predecessors

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>
This commit is contained in:
Keith Randall 2015-08-12 14:51:24 -07:00
parent 514ab7c385
commit 867662da6a
2 changed files with 12 additions and 5 deletions

View 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 {

View 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)