From 9aba7e76f605f7c4fad49886e710152730c34b69 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Mon, 5 Oct 2015 13:48:40 -0700 Subject: [PATCH] [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 Run-TryBot: David Chase --- src/cmd/compile/internal/gc/ssa.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index f4d5946c03..7e00fc9162 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -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)