Skip to content

Commit

Permalink
cmd/compile: do not write implicit conversion for append in Unified IR
Browse files Browse the repository at this point in the history
Same as CL 418475, but for Unified IR.

Updates golang#53888
Fixes golang#54337

Change-Id: I31d5a7af04d8e3902ed25db85009d46ea4c38dbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/422040
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
  • Loading branch information
cuonglm authored and jproberts committed Aug 10, 2022
1 parent 0c869bf commit c962958
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/cmd/compile/internal/noder/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,13 @@ func (r *reader) expr() (res ir.Node) {
case ir.OAPPEND:
n := n.(*ir.CallExpr)
n.RType = r.rtype(pos)
// For append(a, b...), we don't need the implicit conversion. The typechecker already
// ensured that a and b are both slices with the same base type, or []byte and string.
if n.IsDDD {
if conv, ok := n.Args[1].(*ir.ConvExpr); ok && conv.Op() == ir.OCONVNOP && conv.Implicit() {
n.Args[1] = conv.X
}
}
case ir.OCOPY:
n := n.(*ir.BinaryExpr)
n.RType = r.rtype(pos)
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/compile/internal/test/issue53888_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !race && !goexperiment.unified
//go:build !race

package test

Expand All @@ -11,7 +11,6 @@ import (
"testing"
)

// TODO(cuonglm,mdempsky): figure out why Unifed IR failed?
func TestAppendOfMake(t *testing.T) {
testenv.SkipIfOptimizationOff(t)
for n := 32; n < 33; n++ { // avoid stack allocation of make()
Expand Down

0 comments on commit c962958

Please sign in to comment.