aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/check.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/check.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/check.go')
-rw-r--r--src/cmd/compile/internal/ssa/check.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/check.go b/src/cmd/compile/internal/ssa/check.go
index e5de48965b..82d7b7687b 100644
--- a/src/cmd/compile/internal/ssa/check.go
+++ b/src/cmd/compile/internal/ssa/check.go
@@ -309,6 +309,39 @@ func checkFunc(f *Func) {
}
}
}
+
+ // Check that if a tuple has a memory type, it is second.
+ for _, b := range f.Blocks {
+ for _, v := range b.Values {
+ if v.Type.IsTuple() && v.Type.FieldType(0).IsMemory() {
+ f.Fatalf("memory is first in a tuple: %s\n", v.LongString())
+ }
+ }
+ }
+
+ // Check that only one memory is live at any point.
+ // TODO: make this check examine interblock.
+ if f.scheduled {
+ for _, b := range f.Blocks {
+ var mem *Value // the live memory
+ for _, v := range b.Values {
+ if v.Op != OpPhi {
+ for _, a := range v.Args {
+ if a.Type.IsMemory() || a.Type.IsTuple() && a.Type.FieldType(1).IsMemory() {
+ if mem == nil {
+ mem = a
+ } else if mem != a {
+ f.Fatalf("two live mems @ %s: %s and %s", v, mem, a)
+ }
+ }
+ }
+ }
+ if v.Type.IsMemory() || v.Type.IsTuple() && v.Type.FieldType(1).IsMemory() {
+ mem = v
+ }
+ }
+ }
+ }
}
// domCheck reports whether x dominates y (including x==y).