cmd/compile: run write barriers before LLVM emission - #32
Merged
Conversation
zhouguangyuan0718
force-pushed
the
codex/post-expand-llvm-emission
branch
from
August 1, 2026 04:53
b1149fd to
41b7521
Compare
zhouguangyuan0718
changed the base branch from
go1.27.master
to
codex/alloca-statepoint-mutation-correctness
August 1, 2026 04:54
zhouguangyuan0718
force-pushed
the
codex/post-expand-llvm-emission
branch
from
August 1, 2026 08:43
41b7521 to
71790dd
Compare
This was referenced Aug 1, 2026
zhouguangyuan0718
changed the base branch from
codex/alloca-statepoint-mutation-correctness
to
go1.27.master
August 1, 2026 08:48
zhouguangyuan0718
force-pushed
the
codex/post-expand-llvm-emission
branch
4 times, most recently
from
August 2, 2026 03:14
b5171a2 to
f042189
Compare
zhouguangyuan0718
force-pushed
the
codex/post-expand-llvm-emission
branch
from
August 2, 2026 03:23
f042189 to
15b0620
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
llvm.go.gc.write.barrierwhile preserving the current branchy Go control flowAuxCallas physical ABI authority forruntime.wbZero/runtime.wbMove, while restoring their semantic LLVM parameters toptrgo-async-unsafeto every LLVM-emitted function; LLVM PR cmd/objview: add metadata-aware text disassembly #19 therefore emits whole-functionPCDATA_UnsafePoint=-2Unsafe-point model
This version intentionally uses the complete conservative model requested for the first functional write-barrier implementation: every LLVM-emitted function is asynchronous-unsafe for its entire body.
There is no interval scan, unsafe-point start/end intrinsic, SelectionDAG marker, or partial range protocol in this PR. Removing the old
WriteMemmarker also restores normal optimization; the memory-order test accepts inlining and load forwarding while still checking the write barrier and resulting store.Exact interval marking is deferred. The previous range-emission prototype is preserved at codex/post-expand-llvm-emission-ranges-backup.
Rebase and prerequisites
Rebased onto
go1.27.master@912359eeecb1b00c280bd857e220857de32dbf83, including the merged post-construction nilcheck-marker expansion (#38). This branch preserves that implementation unchanged and does not restore the oldBlockEndsCFG bypass.Pointer allocas are handled exclusively by the #33 / LLVM #18 deopt ptrmap model. This PR contains no capture analysis, fixed-stack preload, alloca relocation, or post-call write-back implementation.
Merged prerequisites:
runtime.newprocpointer typing: cmd/compile: preserve newproc pointer argument in LLVM IR #34Open prerequisite:
Statepoint and SSA integration
mixedABI: four ordinary safepoints select bitmap{2}, while morestack selects entry bitmap{2,4,18}OpNilChecktombstone that writebarrier leaves beforeearly deadcodeBlockFirstlowering and all fourBlockInvalidskip paths; unexpected block kinds now use the existing fail-closed pathruntime.newproc,wbZero, andwbMovein onellvmStaticCallSignaturepath: validate each raw ABIInternal uintptr signature, then construct the semantic LLVM pointer signature withoutptrtointadapter valueswbZero/wbMoveas direct gc-leaf calls; focused checks reject any statepoint that targets either helperruntime.panicmemstatepointsValidation
make.bashtoolchain rebuild with the latest vendored go-llvm and exact LLVM payloadgo test -count=1 -tags="llvm23 dynamicllvm" cmd/compile/internal/ssa cmd/llvmtoolexecopt -passes=default<O2>, RS4GC rewritten verification,llc -verify-machineinstrs, MIR and object generation through focused testscmd/internal/testdir Test/LLVM: all 51 codegen and all 47 runtime whitelist caseswbZero/wbMove, writebarrier IR, concurrent GC, and stack-growth suitesgit diff --checkScope
This first functional version keeps the branches generated by the Go writebarrier pass. A later optimization can use a more constrained late-expanded intrinsic and exact unsafe intervals. StackObjects precision and the postponed linker indirect-call nosplit graph issue are not included.