Skip to content

[Go] Encode ABI0 in function symbol names - #77

Merged
zhouguangyuan0718 merged 1 commit into
llvm23.1.masterfrom
review/runtime-abi0-symbol-resolution
Aug 13, 2026
Merged

[Go] Encode ABI0 in function symbol names#77
zhouguangyuan0718 merged 1 commit into
llvm23.1.masterfrom
review/runtime-abi0-symbol-resolution

Conversation

@zhouguangyuan0718

@zhouguangyuan0718 zhouguangyuan0718 commented Aug 13, 2026

Copy link
Copy Markdown

Use the LLVM symbol name as the sole ABI identity contract for Go functions:

  • ABIInternal declarations and definitions keep their logical Go name.
  • ABI0 declarations and definitions use the reserved <ABI0> suffix.
  • GoObj strips <ABI0> and writes ABI0; unsuffixed Go function symbols write ABIInternal.
  • Function calling conventions remain the lowering contract and are checked against the ABI0 suffix.
  • Remove goobj.symbol.name metadata and MC ABI override state.
  • Late runtime.morestack* calls use suffixed ABI0 names; unsuffixed late call relocations such as write barriers resolve as ABIInternal.

The tests cover same-name ABI0/ABIInternal definitions, declarations referenced through function pointers, mismatch rejection, x86_64/AArch64 morestack lowering, write barriers, and raw MC call/data relocation defaults.

Validation:

  • 15 focused CodeGen/GoObj lit tests passed locally on macOS arm64.
  • MC/GoObj lit suite passed 4/4.
  • A Go toolchain built successfully against this payload.
  • Go SSA tests, ABI0 cgo compile/link/execute, and LLVM hello-world compile/link/execute passed.

@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

Use a reserved <ABI0> suffix as the sole ABI0 function identity across IR declarations, definitions, MC symbols, and GoObj references. Strip the suffix while writing GoObj and preserve unsuffixed ABIInternal function names.\n\nRemove goobj.symbol.name and MC ABI override state. Late morestack calls acquire the ABI0 suffix, while unsuffixed late call relocations such as write barriers resolve as ABIInternal.
@zhouguangyuan0718
zhouguangyuan0718 force-pushed the review/runtime-abi0-symbol-resolution branch from e90dafe to 0c3e791 Compare August 13, 2026 09:34
@zhouguangyuan0718
zhouguangyuan0718 merged commit 44d51fa into llvm23.1.master Aug 13, 2026
8 checks passed
zhouguangyuan0718 added a commit that referenced this pull request Aug 13, 2026
## Summary

- use `go-nosplit` as the sole opt-out from the native Go stack check;
split functions call `runtime.morestack*<ABI0>` with an ordinary target
call
- emit one function-level `EntryArgsStackMapID` record for every GoObj
Go function, independent of split/nosplit behavior
- serialize the entry map as map 0 and use the Machine-CFG-derived PCSP
stream to restore map 0 on entry-stack-depth paths, without identifying
`runtime.morestack*` in GoObj emission
- serialize ordinary statepoints as additional live maps and let same-PC
statepoints override a CFG map-0 transition
- retain complete ABI register homes for morestack retries while
omitting unused, potentially poison incoming pointer values from the
entry GC bitmap
- model `go-systemstack` with `g.stackguard1` and `runtime.morestackc`

## Stack position

This is 2/3 in the runtime LLVM support stack.

Depends on #77.
Next/final layer: #76, X86 ABI0/ABIInternal boundary repair.

#75 has been folded into this PR so the stack semantics and the
entry-map contract can be reviewed as one coherent change.

## Testing

- fresh Release build of `llc` for X86 and AArch64
- 12 `GoObjStackMapUtilsTest` unit tests
- 38 Generic/X86/AArch64 GoObj codegen tests
- dedicated object test covering map 0 -> ordinary map 1 -> CFG-derived
map 0 on both targets
zhouguangyuan0718 added a commit that referenced this pull request Aug 13, 2026
## Summary

- keep R14 and XMM15 reserved under both Go calling conventions and
retain the shared Go preserved-register model
- repair ABIInternal reserved state in a late X86 machine pass after
register allocation, frame lowering, and scheduling
- identify direct ABI0 callees solely through the `<ABI0>` symbol
suffix; statepoints use their existing calling-convention operand
- leave late special calls outside the ordinary ABI transition path:
morestack resumes through `gogo`, and write-barrier thunks use their
dedicated ABIInternal clobber contract
- keep SP-relative Go locals while preserving ABI-specific fixed
incoming argument homes
- emit native-compatible symbol-free x86 TLS relocations for the R14
reload

## Design

R14 and XMM15 are fixed reserved registers rather than ordinary
caller-saved or callee-saved allocation resources. The transition repair
therefore does not participate in SelectionDAG lowering and does not
require a target pseudo or a distinct ABI0 register mask.

The `x86-go-abi` pre-emit pass scans finalized MachineInstr calls. For
an ordinary Go call, `<ABI0>` is the only ABI0 identity. It inserts
`XORPS XMM15, XMM15` and a TLS reload of R14 before ABI0-to-ABIInternal
calls or after ABIInternal-to-ABI0 calls.

Calls inserted late without the ordinary Go call mask are intentionally
ignored. This matches native Go behavior for split-stack morestack calls
and write-barrier thunks.

## Stack position

This is the X86 ABI-boundary layer on top of merged #73 and merged #77.

#71 remains the temporary cross-repository integration and payload PR
until this PR is merged.

## Testing

- independent Release plus assertions build of `llc` and `FileCheck`
- focused LLVM lit validation: 7 of 7 passed
- verified normal calls, statepoints, stack-return statepoints, GoObj
relocations, stack growth, PCSP CFG handling, and ABI symbol naming
- verified pass timing: no repair at finalize-isel or immediately before
`x86-go-abi`; repair appears only after the late pass
- verified native-special behavior: no repair is inserted after
morestack or write-barrier calls
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