Skip to content

[AUTOMATED] Preserve adjacent AArch64 Go scalar argument spills - #1809

Merged
mahaloz merged 1 commit into
mainfrom
automated/go-arm64-scalar-stack-slot-width
Nov 19, 2026
Merged

mahaloz merged 1 commit into
mainfrom
automated/go-arm64-scalar-stack-slot-width

Conversation

@mahaloz

@mahaloz mahaloz commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

[AUTOMATED] When two int64 inputs spill to the stack on AArch64 Go, Kuna names the first input and leaves the second as v1. Reproduce with Go 1.27.2 and Kuna's processor specs.

set -eu
d=$(mktemp -d)
cat > "$d/spills.go" <<'GO'
package main
import "os"
var sink int64
//go:noinline
func TwoSpills(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, x, y int64) int64 {
    return x*7 + y
}
func main() {
    sink = TwoSpills(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,int64(len(os.Args)),13)
}
GO
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags='-s -w' -o "$d/spills" "$d/spills.go"
p='int8 TwoSpills(int8 a0,int8 a1,int8 a2,int8 a3,int8 a4,int8 a5,int8 a6,int8 a7,int8 a8,int8 a9,int8 a10,int8 a11,int8 a12,int8 a13,int8 a14,int8 a15,int8 x,int8 y)'
kuna decompile "$d/spills" main.TwoSpills --language go --sleighpath "${KUNA_SPECS:-specs}" \
    --option godwarfsig off --assert-strict --assert "prototype main.TwoSpills $p"

Stock prints return x * 7 + v1. With the change, Kuna prints return x * 7 + y.

The AArch64 Go compiler spec now advances scalar spill slots by eight bytes. The stage checks two adjacent spills and the last argument register. Median CPU time changed by −0.25% in the paired spill comparison.

Model: openai/gpt-6.2-sol

@mahaloz
mahaloz merged commit d532ab9 into main Nov 19, 2026
9 checks passed
@mahaloz
mahaloz deleted the automated/go-arm64-scalar-stack-slot-width branch November 19, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant