aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile
diff options
context:
space:
mode:
authorMartin Möhrmann <martin@golang.org>2021-07-06 21:45:02 +0200
committerMartin Möhrmann <martin@golang.org>2021-08-23 19:49:23 +0000
commit0a7f00ae239570d664488085f9c395919bc69066 (patch)
treef22eaba8bf470e8968be6f761fdd2fe86a7c5a09 /src/cmd/compile
parent6b9e3f883e6820a1e94448ca81eba62341cd4836 (diff)
downloadgo-0a7f00ae239570d664488085f9c395919bc69066.tar.gz
go-0a7f00ae239570d664488085f9c395919bc69066.zip
cmd/compile: do not mark arrays used for map initialization noalg
Arrays marked noalg are created by the compiler to hold keys and values to initialize map literals. The ssa backend creates a pointer type for the array type when creating an OpAddr while processing the loop that initializes the map from the arrays. The pointer type does not inherit the noalg property but points to the noalg array type. This causes values created through reflect of types that should be equal to compare unequal because the noalg and alg type might be compared and these are not the same. A similar problem occurred in #32595 for argument arrays of defer structs. Created #47904 to track improve noalg handling to be able to reintroduce this optimization again. Fixes #47068 Change-Id: I87549342bd404b98d71a3c0f33e3c169e9d4efc8 Reviewed-on: https://go-review.googlesource.com/c/go/+/344349 Trust: Martin Möhrmann <martin@golang.org> Run-TryBot: Martin Möhrmann <martin@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile')
-rw-r--r--src/cmd/compile/internal/walk/complit.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/walk/complit.go b/src/cmd/compile/internal/walk/complit.go
index 6c6b4982a0..e8e941dd91 100644
--- a/src/cmd/compile/internal/walk/complit.go
+++ b/src/cmd/compile/internal/walk/complit.go
@@ -440,8 +440,8 @@ func maplit(n *ir.CompLitExpr, m ir.Node, init *ir.Nodes) {
tk := types.NewArray(n.Type().Key(), int64(len(entries)))
te := types.NewArray(n.Type().Elem(), int64(len(entries)))
- tk.SetNoalg(true)
- te.SetNoalg(true)
+ // TODO(#47904): mark tk and te NoAlg here once the
+ // compiler/linker can handle NoAlg types correctly.
types.CalcSize(tk)
types.CalcSize(te)