aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/wasm
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2018-06-23 13:23:52 -0400
committerCherry Zhang <cherryyz@google.com>2018-06-27 14:30:00 +0000
commit1d303a00862eb4222640806ece5608bb1314a597 (patch)
tree9ebf33847a0106ebcb3d8279806877d8eef9839f /src/cmd/compile/internal/wasm
parentf03ee913e210e1b09bd33ed35c03ec8e4fc270be (diff)
downloadgo-1d303a00862eb4222640806ece5608bb1314a597.tar.gz
go-1d303a00862eb4222640806ece5608bb1314a597.zip
cmd/compile: fold offset into address on Wasm
On Wasm, the offset was not folded into LoweredAddr, so it was not rematerializeable. This led to the address-taken operation in some cases generated too early, before the local variable becoming live. The liveness code thinks the variable live when the address is taken, then backs it up to live at function entry, then complains about it, because nothing other than arguments should be live on entry. This CL folds the offset into the address operation, so it is rematerializeable and so generated right before use, after the variable actually becomes live. It might be possible to relax the liveness code not to think a variable live when its address being taken, but until the address actually being used. But it would be quite complicated. As we're late in Go 1.11 freeze, it would be better not to do it. Also, I think the address operation is rematerializeable now on all architectures, so this is probably less necessary. This may also be a slight optimization, as the address+offset is now rematerializeable, which can be generated on the Wasm stack, without using any "registers" which are emulated by local variables on Wasm. I don't know how to do benchmarks on Wasm. At least, cmd/go binary size shrinks 9K. Fixes #25966. Change-Id: I01e5869515d6a3942fccdcb857f924a866876e57 Reviewed-on: https://go-review.googlesource.com/120599 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Richard Musiol <neelance@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/wasm')
-rw-r--r--src/cmd/compile/internal/wasm/ssa.go16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/cmd/compile/internal/wasm/ssa.go b/src/cmd/compile/internal/wasm/ssa.go
index 8daf749a12..d82b1f7953 100644
--- a/src/cmd/compile/internal/wasm/ssa.go
+++ b/src/cmd/compile/internal/wasm/ssa.go
@@ -232,19 +232,13 @@ func ssaGenValueOnStack(s *gc.SSAGenState, v *ssa.Value) {
case ssa.OpWasmLoweredAddr:
p := s.Prog(wasm.AGet)
- switch n := v.Aux.(type) {
+ p.From.Type = obj.TYPE_ADDR
+ switch v.Aux.(type) {
case *obj.LSym:
- p.From = obj.Addr{Type: obj.TYPE_ADDR, Name: obj.NAME_EXTERN, Sym: n}
+ gc.AddAux(&p.From, v)
case *gc.Node:
- p.From = obj.Addr{
- Type: obj.TYPE_ADDR,
- Name: obj.NAME_AUTO,
- Reg: v.Args[0].Reg(),
- Offset: n.Xoffset,
- }
- if n.Class() == gc.PPARAM || n.Class() == gc.PPARAMOUT {
- p.From.Name = obj.NAME_PARAM
- }
+ p.From.Reg = v.Args[0].Reg()
+ gc.AddAux(&p.From, v)
default:
panic("wasm: bad LoweredAddr")
}