[dev.ssa] cmd/compile: treat control ops as live at end of block

Failure to treat control ops as live can lead
to them being eliminated when they live in
other blocks.

Change-Id: I604a1977a3d3884b1f4516bea4e15885ce38272d
Reviewed-on: https://go-review.googlesource.com/13138
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2015-08-04 14:22:29 -07:00
parent 54dca047dd
commit 573c791e81
3 changed files with 43 additions and 1 deletions

View file

@ -440,6 +440,9 @@ func live(f *Func) [][]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.
@ -456,7 +459,7 @@ func live(f *Func) [][]ID {
}
// 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])