1
0
mirror of https://github.com/golang/go synced 2024-10-05 16:41:21 -06:00

[dev.ssa] cmd/compile: Eval append args after growslice

For appending large types, we want to evaluate the
values being appended after the growslice call, not before.
Evaluating them before leads to phi operations on large types
which confuses the lowering pass.

The order pass has already removed any side-effects from the
values being appended, so it doesn't matter if we do this
last eval before or after the growslice call.

This change fixes a bunch (but not all) of our failed lowerings.

Change-Id: I7c697d4d5275d71b7ef4677b830fd86c52ba03a4
Reviewed-on: https://go-review.googlesource.com/15430
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
This commit is contained in:
Keith Randall 2015-10-05 13:48:40 -07:00
parent 579ccd831f
commit 9aba7e76f6

View File

@ -1860,18 +1860,12 @@ func (s *state) expr(n *Node) *ssa.Value {
// Evaluate slice
slice := s.expr(n.List.N)
// Evaluate args
nargs := int64(count(n.List) - 1)
args := make([]*ssa.Value, 0, nargs)
for l := n.List.Next; l != nil; l = l.Next {
args = append(args, s.expr(l.N))
}
// Allocate new blocks
grow := s.f.NewBlock(ssa.BlockPlain)
assign := s.f.NewBlock(ssa.BlockPlain)
// Decide if we need to grow
nargs := int64(count(n.List) - 1)
p := s.newValue1(ssa.OpSlicePtr, pt, slice)
l := s.newValue1(ssa.OpSliceLen, Types[TINT], slice)
c := s.newValue1(ssa.OpSliceCap, Types[TINT], slice)
@ -1901,6 +1895,13 @@ func (s *state) expr(n *Node) *ssa.Value {
// assign new elements to slots
s.startBlock(assign)
// Evaluate args
args := make([]*ssa.Value, 0, nargs)
for l := n.List.Next; l != nil; l = l.Next {
args = append(args, s.expr(l.N))
}
p = s.variable(&ptrVar, pt) // generates phi for ptr
c = s.variable(&capVar, Types[TINT]) // generates phi for cap
p2 := s.newValue2(ssa.OpPtrIndex, pt, p, l)