cmd/compile: use typed byval for stack ABI inputs - #138
Merged
Conversation
zhouguangyuan0718
force-pushed
the
codex/go-typed-byval
branch
6 times, most recently
from
August 16, 2026 18:02
1a6acf8 to
c9b317e
Compare
zhouguangyuan0718
force-pushed
the
codex/go-typed-byval
branch
from
August 17, 2026 09:52
c9b317e to
3b7f50d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change uses the Go ABI allocator as the source of truth for LLVM input carriers. A non-empty input assigned wholly to the Go stack is emitted as a typed, aligned byval pointer; a register-assigned input remains a direct LLVM value. Results are intentionally unchanged.
For a memory-backed argument whose current SSA memory state is already the call state, the frontend passes the existing address directly. A pure SSA value, or a value that must preserve an earlier memory state, uses an ordinary entry alloca plus store as the byval source. Standard LLVM byval copying remains the correctness mechanism.
LLVM PR #85 recognizes only a strict private alloca plus stores plus one byval-consumer shape and forwards those stores into the final outgoing stack argument area. The predicate is now a shared target-independent CodeGen analysis used by both SelectionDAG and the Go statepoint plugin. Consequently, the plugin does not manufacture a
deoptuse for an ephemeral outgoing carrier and accidentally block the later forwarding. A carrier spanning an intervening call remains an ordinary pointer-containing stack object at every safepoint.Incoming argument-copy elision remains responsible for fixed formal-argument homes, while late byval forwarding skips fixed objects, so the two optimizations do not overlap. Pointer values loaded from incoming homes continue to use ordinary statepoint spill slots; this change does not reuse byval fields as spill slots and does not require readonly or mutation analysis.
The LLVM base calling convention expresses AArch64 and X86 assignment with TableGen rules plus CCState. Direct inputs have no stack fallback, so any carrier/allocation mismatch fails closed. Register fixed homes are retained and the result ABI remains unchanged.
Validation for the coordinated release and Go head:
goallc-llvm23.1.0-20260818T010709Z040059c00d16bfb643a87bf77d162f926a96466f8e4ba75be3archive/tarLLVM O2 dependency closure: pass through compile, statepoint, llc/GoObj, link, and package testsruntime.throw64 to 48 bytes,runtime.fatalthrow80 to 64 bytes,runtime.getGCMaskOnDemand96 to 80 bytesabi-differential/machine-args-pointer-maps: pass after recording the already-required 0/16 Go ABI frame layout in its hand-written MIRfixedbugs/issue19658.go: pass; the full highly parallel local run timed that case out under loadcompress/flatestill reaches the independent stack-result problem incompress/flate.indexTokens. A dedicated result carrier is intentionally outside this input-only change.