From: Keith Randall Date: Mon, 4 Dec 2017 21:30:13 +0000 (-0800) Subject: cmd/compile: fix noopt builder, weird append case X-Git-Tag: go1.10beta1~38 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9d70b3ae04316c5753435dddee54fe7373502e09;p=gostls13.git cmd/compile: fix noopt builder, weird append case Turn off append-to-itself optimization if optimizations are turned off. This optimization triggered a bug when doing s = append(s, s) where we write to the leftmost s before reading the rightmost s. Update #17039 Change-Id: I21996532d20a75db6ec8d49db50cb157a1360b80 Reviewed-on: https://go-review.googlesource.com/81816 Run-TryBot: Keith Randall Reviewed-by: Brad Fitzpatrick Reviewed-by: David Chase TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index 36dd1a4be4..fe062da409 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -737,7 +737,7 @@ func (s *state) stmt(n *Node) { // Check whether we're writing the result of an append back to the same slice. // If so, we handle it specially to avoid write barriers on the fast // (non-growth) path. - if !samesafeexpr(n.Left, rhs.List.First()) { + if !samesafeexpr(n.Left, rhs.List.First()) || Debug['N'] != 0 { break } // If the slice can be SSA'd, it'll be on the stack,