aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/rewriteWasm.go
diff options
context:
space:
mode:
authorDavid Chase <drchase@google.com>2018-07-03 11:34:38 -0400
committerDavid Chase <drchase@google.com>2018-07-12 18:45:31 +0000
commit0029cd479e344e0fa6930331cf86e6f985508163 (patch)
tree79e951dc80efaad1863fe4bfc08ca06e727804b7 /src/cmd/compile/internal/ssa/rewriteWasm.go
parentbb364d49a9db585534aac965d1068bee0bda3054 (diff)
downloadgo-0029cd479e344e0fa6930331cf86e6f985508163.tar.gz
go-0029cd479e344e0fa6930331cf86e6f985508163.zip
cmd/compile: add LocalAddr that takes SP,mem operands
Lack of a well-defined order between VarDef and related address operations sometimes causes problems with store order and write barrier transformations; glitches in the order are made irreparable (by later optimizations) if the two parts of the glitch straddle a split in the original block caused by insertion of a write barrier diamond. Fix this by creating a LocalAddr for addresses of locals (what VarDef matters for) that takes a memory input to help make the order explicit. Addr is modified to only be legal for SB operand, so there is no overlap between Addr and LocalAddr uses (there may be some downstream cleanup from this). Changes to generic.rules and rewrite.go ensure that codegen tests continue to pass; CSE of LocalAddr is impaired, not quite sure of the cost. Fixes #26105. Change-Id: Id4192b4440aa4e9d7ba54a465c456df9b530b515 Reviewed-on: https://go-review.googlesource.com/122483 Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/rewriteWasm.go')
-rw-r--r--src/cmd/compile/internal/ssa/rewriteWasm.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/rewriteWasm.go b/src/cmd/compile/internal/ssa/rewriteWasm.go
index 26dd254952..c07651ef0e 100644
--- a/src/cmd/compile/internal/ssa/rewriteWasm.go
+++ b/src/cmd/compile/internal/ssa/rewriteWasm.go
@@ -237,6 +237,8 @@ func rewriteValueWasm(v *Value) bool {
return rewriteValueWasm_OpLess8U_0(v)
case OpLoad:
return rewriteValueWasm_OpLoad_0(v)
+ case OpLocalAddr:
+ return rewriteValueWasm_OpLocalAddr_0(v)
case OpLsh16x16:
return rewriteValueWasm_OpLsh16x16_0(v)
case OpLsh16x32:
@@ -2496,6 +2498,20 @@ func rewriteValueWasm_OpLoad_0(v *Value) bool {
}
return false
}
+func rewriteValueWasm_OpLocalAddr_0(v *Value) bool {
+ // match: (LocalAddr {sym} base _)
+ // cond:
+ // result: (LoweredAddr {sym} base)
+ for {
+ sym := v.Aux
+ _ = v.Args[1]
+ base := v.Args[0]
+ v.reset(OpWasmLoweredAddr)
+ v.Aux = sym
+ v.AddArg(base)
+ return true
+ }
+}
func rewriteValueWasm_OpLsh16x16_0(v *Value) bool {
b := v.Block
_ = b