}
}
+ for _, b := range f.Blocks {
+ if b.Control != nil {
+ if !valueMark[b.Control.ID] {
+ f.Fatalf("control value for %s is missing: %v", b, b.Control)
+ }
+ }
+ }
for _, id := range f.bid.free {
if blockMark[id] {
f.Fatalf("used block b%d in free list", id)
// Start with known live values at the end of the block
s.clear()
s.addAll(live[b.ID])
+ if b.Control != nil {
+ s.add(b.Control.ID)
+ }
// Propagate backwards to the start of the block
// Assumes Values have been scheduled.
}
// for each predecessor of b, expand its list of live-at-end values
- // inv: s contains the values live at the start of b (excluding phi inputs)
+ // invariant: s contains the values live at the start of b (excluding phi inputs)
for i, p := range b.Preds {
t.clear()
t.addAll(live[p.ID])
--- /dev/null
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ssa
+
+import "testing"
+
+func TestLiveControlOps(t *testing.T) {
+ c := testConfig(t)
+ f := Fun(c, "entry",
+ Bloc("entry",
+ Valu("mem", OpArg, TypeMem, 0, ".mem"),
+ Valu("x", OpAMD64MOVBconst, TypeInt8, 0, 1),
+ Valu("y", OpAMD64MOVBconst, TypeInt8, 0, 2),
+ Valu("a", OpAMD64TESTB, TypeBool, 0, nil, "x", "y"),
+ Valu("b", OpAMD64TESTB, TypeBool, 0, nil, "y", "x"),
+ If("a", "if", "exit"),
+ ),
+ Bloc("if",
+ If("b", "plain", "exit"),
+ ),
+ Bloc("plain",
+ Goto("exit"),
+ ),
+ Bloc("exit",
+ Exit("mem"),
+ ),
+ )
+ regalloc(f.f)
+ checkFunc(f.f)
+}