Skip to content

[GoObj] Distinguish builtin and linkname references by name - #79

Merged
zhouguangyuan0718 merged 3 commits into
goallc:llvm23.1.masterfrom
zhouguangyuan0718:codex/goobj-builtin-suffix
Aug 14, 2026
Merged

[GoObj] Distinguish builtin and linkname references by name#79
zhouguangyuan0718 merged 3 commits into
goallc:llvm23.1.masterfrom
zhouguangyuan0718:codex/goobj-builtin-suffix

Conversation

@zhouguangyuan0718

@zhouguangyuan0718 zhouguangyuan0718 commented Aug 14, 2026

Copy link
Copy Markdown

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.
  • definitions keep their canonical names.
  • malformed or conflicting suffix/metadata combinations fail closed.

GoObj strips the reference suffix, writes builtin references as PkgIdxBuiltin, and writes linkname pulls as non-package references with SymFlagLinkname. The standard-library bit is also carried through !goobj.config, which is required for linker authorization of //go:linknamestd pulls 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; -linkshared deliberately 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:

  • focused X86/AArch64 stack-growth and write-barrier lit tests: 5/5 passed, including -linkshared fallback
  • broader Generic/X86/AArch64 Go and GoObj lit coverage: 60 passed, 1 unsupported; the only excluded failure is the pre-existing stale REP expectation in go-memset-inline.ll
  • Go compiler focused tests and 15 LLVM codegen fixtures passed with the dependent Go change
  • a full Go/LLVM joint make.bash completed on darwin/arm64
  • runtime and its dependency closure compiled through LLVM, produced GoObj/archive output, and reached final link; the remaining failure is the independent callRet nosplit chain exceeding the 792-byte limit by 8 bytes

@github-actions

Copy link
Copy Markdown

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.

  • All contributions to LLVM must follow our LLVM AI Tool Use Policy. In particular, if you used AI while working on this PR, remember to add a note to the PR description.
  • The LLVM Code-Review Policy and Practices document contains practical information about the PR process, including how patches are reviewed and accepted, and who can review a PR.
  • Our LLVM Developer Policy describes our expectations for code quality, commit summaries and contains notes on our CI system.

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 questions

How 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 @ followed by their GitHub username.

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,
The LLVM Community

@zhouguangyuan0718
zhouguangyuan0718 merged commit 3710742 into goallc:llvm23.1.master Aug 14, 2026
8 checks passed
zhouguangyuan0718 added a commit to goallc/go that referenced this pull request Aug 14, 2026
## 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
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