cmd/compile: preserve newproc pointer argument in LLVM IR - #34
Merged
Conversation
zhouguangyuan0718
force-pushed
the
codex/newproc-pointer-arg
branch
from
August 1, 2026 11:20
7bb9e20 to
c6b672e
Compare
zhouguangyuan0718
force-pushed
the
codex/newproc-pointer-arg
branch
from
August 1, 2026 11:52
c6b672e to
4bce9b7
Compare
zhouguangyuan0718
force-pushed
the
codex/newproc-pointer-arg
branch
from
August 1, 2026 13:40
4bce9b7 to
b5eb872
Compare
zhouguangyuan0718
force-pushed
the
codex/newproc-pointer-arg
branch
from
August 1, 2026 13:44
b5eb872 to
fb377b4
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.
Summary
runtime.newproccall in LLVM loweringAuxCallcontinues to useuintptrsolely for the physical ABI assignmentptr, matching the actual pointer-shaped closure SSA operandRationale
The compiler lowers a
gostatement as a raw runtime call rather than a normally typedCallExpr. Nativessagenrecords the closure asuintptrinAuxCallto allocate one integer ABI word, while the actual SSA operand andruntime.newproc(fn *funcval)parameter are pointers. Native machine lowering can keep those physical and semantic views separate; LLVM needs the declaration and operand to have the same IR type and statepoint processing must retain the pointer type.This PR handles that one established mismatch. It does not introduce a general runtime signature resolver, inspect compiler builtin models, change
AuxCall, or adapt defer/runtime helper calls.Evidence
The focused fixture produces:
call goabiinternal void @runtime.newproc(ptr %closure)tail call goabiinternal void @runtime.newproc(ptr nonnull %closure)declare goabiinternal void @runtime.newproc(ptr)runtime.newproc(i64)R_CALLARM64:runtime.newprocat an ordinary safepoint, with a distinct morestack safepointThe runtime fixture grows the caller stack, launches an escaping closure, and runs GC in both caller and goroutine for eight rounds.
Validation
Validated after rebasing onto #35:
make.bashtoolchain rebuildgo test -count=1 -tags="llvm23 dynamicllvm" cmd/compile/internal/ssa cmd/llvmtoolexecgo test -count=1 cmd/internal/testdir -run "^Test/LLVM$": 48/48 codegen, ABI differential, alloca-statepoint, 46/46 runtime, and 2/2 fail-closedopt -passes="default<O2>,verify"followed by a second verifier passllc -verify-machineinstrs -filetype=objruntime.newprocrelocation and ordinary safepointgit diff --checkBoundaries
runtime.newprocis changed