aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/schedule.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2017-05-11 14:46:49 -0700
committerKeith Randall <khr@golang.org>2017-05-11 22:16:08 +0000
commit978af9c2dbb4982f62dee6b84c48e06e0d4c085c (patch)
tree0bc3db068108c913903a7b6ab47c383fbd592c9e /src/cmd/compile/internal/ssa/schedule.go
parente5bb5e397d04b137c0fd4da8e137fb4ac431a68c (diff)
downloadgo-978af9c2dbb4982f62dee6b84c48e06e0d4c085c.tar.gz
go-978af9c2dbb4982f62dee6b84c48e06e0d4c085c.zip
cmd/compile: fix store chain in schedule pass
Tuple ops are weird. They are essentially a pair of ops, one which consumes a mem and one which generates a mem (the Select1). The schedule pass didn't handle these quite right. Fix the scheduler to include both parts of the paired op in the store chain. That makes sure that loads are correctly ordered with respect to the first of the pair. Add a check for the ssacheck builder, that there is only one live store at a time. I thought we already had such a check, but apparently not... Fixes #20335 Change-Id: I59eb3446a329100af38d22820b1ca2190ca46a78 Reviewed-on: https://go-review.googlesource.com/43294 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/schedule.go')
-rw-r--r--src/cmd/compile/internal/ssa/schedule.go31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/cmd/compile/internal/ssa/schedule.go b/src/cmd/compile/internal/ssa/schedule.go
index 356d44787f..2e9464eb0d 100644
--- a/src/cmd/compile/internal/ssa/schedule.go
+++ b/src/cmd/compile/internal/ssa/schedule.go
@@ -132,19 +132,20 @@ func schedule(f *Func) {
}
}
+ // TODO: make this logic permanent in types.IsMemory?
+ isMem := func(v *Value) bool {
+ return v.Type.IsMemory() || v.Type.IsTuple() && v.Type.FieldType(1).IsMemory()
+ }
+
for _, b := range f.Blocks {
// Find store chain for block.
// Store chains for different blocks overwrite each other, so
// the calculated store chain is good only for this block.
for _, v := range b.Values {
- if v.Op != OpPhi && v.Type.IsMemory() {
- mem := v
- if v.Op == OpSelect1 {
- v = v.Args[0]
- }
+ if v.Op != OpPhi && isMem(v) {
for _, w := range v.Args {
- if w.Type.IsMemory() {
- nextMem[w.ID] = mem
+ if isMem(w) {
+ nextMem[w.ID] = v
}
}
}
@@ -163,15 +164,15 @@ func schedule(f *Func) {
uses[w.ID]++
}
// Any load must come before the following store.
- if v.Type.IsMemory() || !w.Type.IsMemory() {
- continue // not a load
- }
- s := nextMem[w.ID]
- if s == nil || s.Block != b {
- continue
+ if !isMem(v) && isMem(w) {
+ // v is a load.
+ s := nextMem[w.ID]
+ if s == nil || s.Block != b {
+ continue
+ }
+ additionalArgs[s.ID] = append(additionalArgs[s.ID], v)
+ uses[v.ID]++
}
- additionalArgs[s.ID] = append(additionalArgs[s.ID], v)
- uses[v.ID]++
}
}