[GoObj] Distinguish builtin and linkname references by name - #79
Conversation
|
Hello @zhouguangyuan0718 👋 Thank you for submitting a Pull Request (PR) to the LLVM Project. Since this is your first PR, here are a few useful links covering our main contribution policies and review practices.
Please reply to this message to confirm that you have read these policies, especially the LLVM AI Tool Use Policy, and that any AI tool usage has been noted in the PR description. Frequently asked questionsHow do I add reviewers? This PR will be automatically labeled, and the relevant teams will be notified. For some parts of the project, reviewers may also be added automatically. You can also add reviewers manually using the Reviewers section on this page. If you cannot use that section, it is probably because you do not have write permissions for the repository. In that case, you can request a review by tagging reviewers in a comment using What if there are no comments? If you have not received any comments on your PR after a week, you can request a review by pinging the PR with a comment such as “Ping”. The common courtesy ping rate is once a week. Please remember that you are asking for volunteer time from other developers. Are any special GitHub settings required to contribute to LLVM? We only require contributors to have a public email address associated with their GitHub commits, see this section of LLVM Developer Policy for details. If you have questions, feel free to leave a comment on this PR, or ask on LLVM Discord or LLVM Discourse. Thank you, |
## Summary - carry the runtime-specific LLVM lowering needed to compile the runtime package - encode ordinary GoObj builtin references as `<builtin.N>` LLVM declaration names, created lazily from each exact SSA/AuxCall signature - generate the late-machine-helper classification from `mkbuiltin.go` and eagerly retain only `gcWriteBarrier1..8` plus the three `morestack` ABI0 declarations - keep runtime implementations on their canonical names; ABI0 remains the outer `<ABI0>` suffix - remove the old `!goobj.builtin` reference metadata path and pin the merged LLVM #79 release This replaces the runtime-lowering and builtin portions of #131. The remaining linkname naming contract stays in #131; eager declarations for the full builtin table, provisional `any` signatures, and named-aggregate call-boundary reshaping are deliberately outside this PR. Depends on goallc/llvm-project#79 and release `goallc-llvm23.1.0-20260814T092516Z` (`3710742685729c697378ab13a456484e5693aba9`). ## Validation - `go test cmd/internal/goobj cmd/dist cmd/llvmtoolexec` - `go test -tags="llvm23 dynamicllvm" cmd/compile/internal/ssa` - all 130 LLVM codegen cases on darwin/arm64 - IR -> LLVM O2 -> GoObj -> link -> execute smoke test - LLVM O2/GoObj archive generation for runtime and its exact 28-package dependency closure - generated `builtinlist.go` matches `mkbuiltin.go -stdout` ## Known independent follow-ups - linking the fully LLVM-built runtime closure reaches the existing `callRet: nosplit stack over 792 byte limit` by 8 bytes - `runtime.test` additionally reaches the separate named-aggregate `pageCache` / `PageCache` caller-boundary issue
Go compiler-generated builtin references and source-level linkname pulls can target the same canonical Go symbol while requiring different GoObj reference identities. This change makes the LLVM symbol name the complete reference contract:
<builtin.N>identifies a GoObj builtin reference and embeds its authoritative Go builtin index.<linkname>identifies a source linkname pull.<ABI0>remains an orthogonal, outer suffix.GoObj strips the reference suffix, writes builtin references as
PkgIdxBuiltin, and writes linkname pulls as non-package references withSymFlagLinkname. The standard-library bit is also carried through!goobj.config, which is required for linker authorization of//go:linknamestdpulls from LLVM-built runtime objects.The latest commit completes the declaration-based contract for machine-late helpers. X86 and AArch64 stack-growth/write-barrier expansion locate the suffixed declaration already emitted by the Go compiler and use that exact symbol. LLVM therefore has no duplicate Go builtin table. Production Go IR fails closed when a required declaration is missing;
-linkshareddeliberately falls back to the canonical name, matching native Go's disabled builtin-index references.The dependent Go change is goallc/go#131. It joins the existing GoObj builtin list with the existing typed declarations generated by
mkbuiltin; it does not add another builtin definition list.Validation:
-linksharedfallbackgo-memset-inline.llmake.bashcompleted on darwin/arm64callRetnosplit chain exceeding the 792-byte limit by 8 bytes