diff options
author | Keith Randall <khr@golang.org> | 2017-05-15 09:00:55 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2017-05-15 19:17:35 +0000 |
commit | 256210c719608bb508a59b608a6ae615fbd7f8c0 (patch) | |
tree | 226fd6412cb47d40e7a1ef685decb255c950615b /src/cmd/compile/internal/ssa/trim.go | |
parent | d5e01c044f8674ab6cc62ae6f886163eee572884 (diff) | |
download | go-256210c719608bb508a59b608a6ae615fbd7f8c0.tar.gz go-256210c719608bb508a59b608a6ae615fbd7f8c0.zip |
cmd/compile: better check for single live memory
Enhance the one-live-memory-at-a-time check to run during many
more phases of the SSA backend. Also make it work in an interblock
fashion.
Change types.IsMemory to return true for tuples containing a memory type.
Fix trim pass to build the merged phi correctly. Doesn't affect
code but allows the check to pass after trim runs.
Switch the AddTuple* ops to take the memory-containing tuple argument second.
Update #20335
Change-Id: I5b03ef3606b75a9e4f765276bb8b183cdc172b43
Reviewed-on: https://go-review.googlesource.com/43495
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/trim.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/trim.go | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/ssa/trim.go b/src/cmd/compile/internal/ssa/trim.go index 09e80bdfe5..04b4fd4d54 100644 --- a/src/cmd/compile/internal/ssa/trim.go +++ b/src/cmd/compile/internal/ssa/trim.go @@ -46,10 +46,24 @@ func trim(f *Func) { v.resetArgs() continue } - // Pad the arguments of the remaining phi-ops, so + // Pad the arguments of the remaining phi-ops so // they match the new predecessor count of `s`. - for len(v.Args) < len(s.Preds) { - v.AddArg(v.Args[0]) + // Since s did not have a Phi op corresponding to + // the phi op in b, the other edges coming into s + // must be loopback edges from s, so v is the right + // argument to v! + args := make([]*Value, len(v.Args)) + copy(args, v.Args) + v.resetArgs() + for x := 0; x < j; x++ { + v.AddArg(v) + } + v.AddArg(args[0]) + for x := j + 1; x < ns; x++ { + v.AddArg(v) + } + for _, a := range args[1:] { + v.AddArg(a) } } b.Values[k] = v |