mirror of
https://github.com/golang/go
synced 2024-10-05 20:31:20 -06:00
[dev.ssa] cmd/compile/internal/ssa: ensure Phi ops are scheduled first
Phi ops should always be scheduled first. They have the semantics of all happening simultaneously at the start of the block. The regalloc phase assumes all the phis will appear first. Change-Id: I30291e1fa384a0819205218f1d1ec3aef6d538dd Reviewed-on: https://go-review.googlesource.com/12154 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
parent
337b7e7e3b
commit
4e204b42f5
@ -54,16 +54,28 @@ func schedule(f *Func) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Topologically sort the values in b.
|
|
||||||
order = order[:0]
|
order = order[:0]
|
||||||
|
|
||||||
|
// Schedule phis first
|
||||||
for _, v := range b.Values {
|
for _, v := range b.Values {
|
||||||
if v == b.Control {
|
if v.Op == OpPhi {
|
||||||
|
// TODO: what if a phi is also a control op? It happens for
|
||||||
|
// mem ops all the time, which shouldn't matter. But for
|
||||||
|
// regular ops we might be violating invariants about where
|
||||||
|
// control ops live.
|
||||||
|
if v == b.Control && !v.Type.IsMemory() {
|
||||||
|
f.Unimplementedf("phi is a control op %s %s", v, b)
|
||||||
|
}
|
||||||
|
order = append(order, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Topologically sort the non-phi values in b.
|
||||||
|
for _, v := range b.Values {
|
||||||
|
if v.Op == OpPhi {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if v.Op == OpPhi {
|
if v == b.Control {
|
||||||
// Phis all go first. We handle phis specially
|
|
||||||
// because they may have self edges "a = phi(a, b, c)"
|
|
||||||
order = append(order, v)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if state[v.ID] != unmarked {
|
if state[v.ID] != unmarked {
|
||||||
|
Loading…
Reference in New Issue
Block a user