From ad9e6edfddf7c68b7a549ab7b491919f0980889d Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Mon, 9 Oct 2023 22:39:50 +0700 Subject: [PATCH] cmd/compile: fix wrong argument of OpSelectN during expand_calls Fixes #63462 Change-Id: I5ddf831eab630e23156f8f27a079b4ca4bb3a261 Reviewed-on: https://go-review.googlesource.com/c/go/+/533795 LUCI-TryBot-Result: Go LUCI Reviewed-by: David Chase Reviewed-by: Dmitri Shuralyov Auto-Submit: Cuong Manh Le --- src/cmd/compile/internal/ssa/expand_calls.go | 4 ++++ test/fixedbugs/issue63462.go | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/fixedbugs/issue63462.go diff --git a/src/cmd/compile/internal/ssa/expand_calls.go b/src/cmd/compile/internal/ssa/expand_calls.go index 29c180be34..298e29ec56 100644 --- a/src/cmd/compile/internal/ssa/expand_calls.go +++ b/src/cmd/compile/internal/ssa/expand_calls.go @@ -142,6 +142,10 @@ func expandCalls(f *Func) { call := v.Args[0] aux := call.Aux.(*AuxCall) mem := x.memForCall[call.ID] + if mem == nil { + mem = call.Block.NewValue1I(call.Pos, OpSelectN, types.TypeMem, int64(aux.abiInfo.OutRegistersUsed()), call) + x.memForCall[call.ID] = mem + } i := v.AuxInt regs := aux.RegsOfResult(i) diff --git a/test/fixedbugs/issue63462.go b/test/fixedbugs/issue63462.go new file mode 100644 index 0000000000..09b7e257a2 --- /dev/null +++ b/test/fixedbugs/issue63462.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +func f() { + for b := "" < join([]string{}, "") && true; ; { + _ = b + } +} + +//go:noinline +func join(elems []string, sep string) string { + return "" +} -- 2.44.0