diff options
| author | Keith Randall <khr@golang.org> | 2015-07-13 23:52:59 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2015-07-14 15:39:56 +0000 |
| commit | 4e204b42f5b66ea36f0421098a42addc7c2ba6c7 (patch) | |
| tree | ebae276d22d85cecba7874fe5e0c65da1f832747 /src | |
| parent | 337b7e7e3bb3a6a141d4aa10f8ed79ee33b6f7e9 (diff) | |
| download | go-4e204b42f5b66ea36f0421098a42addc7c2ba6c7.tar.xz | |
[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>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/compile/internal/ssa/schedule.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/ssa/schedule.go b/src/cmd/compile/internal/ssa/schedule.go index 60d2cd5460..15e8ace391 100644 --- a/src/cmd/compile/internal/ssa/schedule.go +++ b/src/cmd/compile/internal/ssa/schedule.go @@ -54,16 +54,28 @@ func schedule(f *Func) { } } - // Topologically sort the values in b. order = order[:0] + + // Schedule phis first for _, v := range b.Values { - if v == b.Control { - continue - } if v.Op == OpPhi { - // Phis all go first. We handle phis specially - // because they may have self edges "a = phi(a, b, c)" + // 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 + } + if v == b.Control { continue } if state[v.ID] != unmarked { |
