1
0
mirror of https://github.com/golang/go synced 2024-11-25 08:07:57 -07:00

cmd/compile: use call block instead of entry block for tail call expansion

The expand-calls pass assumed that tail calls were always done in the
entry block. That used to be true, but with tail calls in wrappers
(enabled by CL 578235) and libfuzzer instrumentation, that is no
longer the case. Libfuzzer instrumentation adds an IF statement to the
start of the wrapper function.

Fixes #69825

Change-Id: I9ab7133691d8235f9df128be39bff154b0b8853b
Reviewed-on: https://go-review.googlesource.com/c/go/+/619075
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
This commit is contained in:
Keith Randall 2024-10-09 09:36:41 -07:00
parent 935bf1395c
commit 5428570af7
2 changed files with 19 additions and 1 deletions

View File

@ -286,7 +286,7 @@ func (x *expandState) rewriteCallArgs(v *Value, firstArg int) {
if v.Op == OpTailLECall { if v.Op == OpTailLECall {
// For tail call, we unwind the frame before the call so we'll use the caller's // For tail call, we unwind the frame before the call so we'll use the caller's
// SP. // SP.
sp = x.f.Entry.NewValue1(src.NoXPos, OpGetCallerSP, x.typs.Uintptr, mem) sp = v.Block.NewValue1(src.NoXPos, OpGetCallerSP, x.typs.Uintptr, mem)
} }
for i, a := range argsWithoutMem { // skip leading non-parameter SSA Args and trailing mem SSA Arg. for i, a := range argsWithoutMem { // skip leading non-parameter SSA Args and trailing mem SSA Arg.

View File

@ -0,0 +1,18 @@
// compile -d=libfuzzer
// Copyright 2024 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 main
type T struct {
A
}
type A struct {
}
//go:noinline
func (a *A) Foo(s [2]string) {
}