Skip to content

Commit 5428570

Browse files
committed
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 935bf13 commit 5428570

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/cmd/compile/internal/ssa/expand_calls.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func (x *expandState) rewriteCallArgs(v *Value, firstArg int) {
286286
if v.Op == OpTailLECall {
287287
// For tail call, we unwind the frame before the call so we'll use the caller's
288288
// SP.
289-
sp = x.f.Entry.NewValue1(src.NoXPos, OpGetCallerSP, x.typs.Uintptr, mem)
289+
sp = v.Block.NewValue1(src.NoXPos, OpGetCallerSP, x.typs.Uintptr, mem)
290290
}
291291

292292
for i, a := range argsWithoutMem { // skip leading non-parameter SSA Args and trailing mem SSA Arg.

test/fixedbugs/issue69825.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// compile -d=libfuzzer
2+
3+
// Copyright 2024 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package main
8+
9+
type T struct {
10+
A
11+
}
12+
13+
type A struct {
14+
}
15+
16+
//go:noinline
17+
func (a *A) Foo(s [2]string) {
18+
}

0 commit comments

Comments
 (0)