From 8c2a8b1771cd7ed2182f4d03b3c4bd09828315ce Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Tue, 13 Apr 2021 18:01:59 -0400 Subject: [PATCH] cmd/compile: always zero the temporary in mapKeyTemp As we are taking its address, always zero it. In many cases the temporary will be optimized out. But in case it does not (e.g. -N, -race), this ensures it has the right liveness information. May fix the noopt builder. Change-Id: I3d5d617c276d2a1a1aaebff813b4cd60bc691592 Reviewed-on: https://go-review.googlesource.com/c/go/+/309771 Trust: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Go Bot Reviewed-by: Than McIntosh --- src/cmd/compile/internal/walk/order.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/walk/order.go b/src/cmd/compile/internal/walk/order.go index 8b30632665..42d9d58971 100644 --- a/src/cmd/compile/internal/walk/order.go +++ b/src/cmd/compile/internal/walk/order.go @@ -306,8 +306,7 @@ func (o *orderState) mapKeyTemp(t *types.Type, n ir.Node) ir.Node { if kt.Align < nt.Align { base.Fatalf("mapKeyTemp: key type is not sufficiently aligned, kt=%v nt=%v", kt, nt) } - clear := base.Flag.Cfg.Instrumenting // clear tmp if instrumenting, as it may be live at an inserted race call - tmp := o.newTemp(kt, clear) + tmp := o.newTemp(kt, true) // *(*nt)(&tmp) = n var e ir.Node = typecheck.NodAddr(tmp) e = ir.NewConvExpr(n.Pos(), ir.OCONVNOP, nt.PtrTo(), e) -- 2.50.0