aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/schedule.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2017-05-15 09:00:55 -0700
committerKeith Randall <khr@golang.org>2017-05-15 19:17:35 +0000
commit256210c719608bb508a59b608a6ae615fbd7f8c0 (patch)
tree226fd6412cb47d40e7a1ef685decb255c950615b /src/cmd/compile/internal/ssa/schedule.go
parentd5e01c044f8674ab6cc62ae6f886163eee572884 (diff)
downloadgo-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/schedule.go')
-rw-r--r--src/cmd/compile/internal/ssa/schedule.go22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/cmd/compile/internal/ssa/schedule.go b/src/cmd/compile/internal/ssa/schedule.go
index 2e9464eb0d..c44c243eac 100644
--- a/src/cmd/compile/internal/ssa/schedule.go
+++ b/src/cmd/compile/internal/ssa/schedule.go
@@ -132,19 +132,14 @@ 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 && isMem(v) {
+ if v.Op != OpPhi && v.Type.IsMemory() {
for _, w := range v.Args {
- if isMem(w) {
+ if w.Type.IsMemory() {
nextMem[w.ID] = v
}
}
@@ -164,7 +159,7 @@ func schedule(f *Func) {
uses[w.ID]++
}
// Any load must come before the following store.
- if !isMem(v) && isMem(w) {
+ if !v.Type.IsMemory() && w.Type.IsMemory() {
// v is a load.
s := nextMem[w.ID]
if s == nil || s.Block != b {
@@ -315,11 +310,7 @@ func storeOrder(values []*Value, sset *sparseSet, storeNumber []int32) []*Value
if v.Op == OpInitMem || v.Op == OpPhi {
continue
}
- a := v
- if v.Op == OpSelect1 {
- a = a.Args[0]
- }
- sset.add(a.MemoryArg().ID) // record that v's memory arg is used
+ sset.add(v.MemoryArg().ID) // record that v's memory arg is used
}
if v.Op == OpNilCheck {
hasNilCheck = true
@@ -335,7 +326,7 @@ func storeOrder(values []*Value, sset *sparseSet, storeNumber []int32) []*Value
for _, v := range stores {
if !sset.contains(v.ID) {
if last != nil {
- f.Fatalf("two stores live simutaneously: %v and %v", v, last)
+ f.Fatalf("two stores live simultaneously: %v and %v", v, last)
}
last = v
}
@@ -362,9 +353,6 @@ func storeOrder(values []*Value, sset *sparseSet, storeNumber []int32) []*Value
}
break
}
- if w.Op == OpSelect1 {
- w = w.Args[0]
- }
w = w.MemoryArg()
}
var stack []*Value