Skip to content

cl: keep pcline anchors valid under full LTO#2097

Merged
xushiwei merged 2 commits into
xgo-dev:mainfrom
zhouguangyuan0718:agent/full-lto-pcline-anchor
Jul 19, 2026
Merged

cl: keep pcline anchors valid under full LTO#2097
xushiwei merged 2 commits into
xgo-dev:mainfrom
zhouguangyuan0718:agent/full-lto-pcline-anchor

Conversation

@zhouguangyuan0718

@zhouguangyuan0718 zhouguangyuan0718 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What changed

  • associate ELF llgo_pcline records with their local PC labels instead of source function symbols
  • update the IR emission test to require a local SHF_LINK_ORDER anchor
  • add a Full LTO build-and-run regression fixture that keeps the affected runtime/pprof path in the link with funcinfo enabled

Why

Full LTO can inline and remove runtime/pprof.writeProfileInternal and writeRuntimeProfile while retaining body-embedded pc-line inline asm. The inline asm previously named the source function as its ELF SHF_LINK_ORDER target, so lld rejected it after that function no longer belonged to an emitted section:

linked-to symbol is not in a section

The local PC label moves with the inline asm and therefore always identifies the final emitted code section, including after Full LTO inlining.

Validation

  • go test ./cl -run 'PCLine|PCLines'
  • go test ./ssa -run 'PCLine|PCLines'
  • go test ./internal/build -run 'PCLine|PCLines'
  • go test ./internal/build/funcinfo -run 'PCLine|PCLines'
  • go test ./cl -run '^TestRunAndTestFromTestlto$/testpcline$' -count=1
  • go test ./cl -run 'TestCompileRuntimeCallerPCLineUsesLocalAnchor|TestRunAndTestFromTestlto/testpcline' -count=1 -coverprofile=/tmp/pr2097-cl.cover (emitPCLineLabel: 88.9%)
  • manually built and ran the reproducer with LLGO_FUNCINFO_SITES=1 -lto=full, both with and without the LLGo LTO plugin

The regression fixture intentionally has no out.ll: the test harness disables LLGO_FUNCINFO while capturing an IR golden, which would bypass the metadata link path this PR needs to exercise.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zhouguangyuan0718
zhouguangyuan0718 force-pushed the agent/full-lto-pcline-anchor branch 3 times, most recently from 1f0e5f6 to 8e195c2 Compare July 16, 2026 00:09
@zhouguangyuan0718
zhouguangyuan0718 marked this pull request as ready for review July 16, 2026 01:45
@zhouguangyuan0718
zhouguangyuan0718 force-pushed the agent/full-lto-pcline-anchor branch from 8e195c2 to acfe10d Compare July 19, 2026 06:51
@zhouguangyuan0718
zhouguangyuan0718 force-pushed the agent/full-lto-pcline-anchor branch from acfe10d to ad8f754 Compare July 19, 2026 13:40
@xushiwei
xushiwei merged commit 56e8d92 into xgo-dev:main Jul 19, 2026
42 checks passed
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.

2 participants