Skip to content

cmd/compile: preserve KeepAlive through LLVM inlining - #82

Merged
zhouguangyuan0718 merged 1 commit into
go1.27.masterfrom
codex/keepalive-operand-bundle
Aug 5, 2026
Merged

cmd/compile: preserve KeepAlive through LLVM inlining#82
zhouguangyuan0718 merged 1 commit into
go1.27.masterfrom
codex/keepalive-operand-bundle

Conversation

@zhouguangyuan0718

Copy link
Copy Markdown

Lower OpKeepAlive and pointer-bearing OpVarLive to an llvm.donothing call carrying a go.keepalive operand bundle. The bundle is a real SSA use that survives LLVM inlining and O2, while llvm.donothing emits no machine instruction. This avoids changing llvm.fake.use or generic LLVM inliner behavior.

The statepoint liveness scan sees operand-bundle inputs, so an inlined KeepAlive keeps the referenced stack object in pointer maps until the source keepalive point.

Depends on goallc/go-llvm#8. The matching go-llvm binding is vendored here.

Tests:

  • go test -tags=llvm23,dynamicllvm cmd/compile/internal/ssa -count=1
  • go test cmd/internal/testdir -run Test/LLVM/codegen/codegen/llvm_memory_order.go -count=1
  • go test cmd/internal/testdir -run Test/LLVM/runtime/stackobj(2)?.go -count=1
  • go test cmd/internal/testdir -run ^Test$/^LLVM$/^codegen -count=1

@zhouguangyuan0718
zhouguangyuan0718 merged commit e56f3c9 into go1.27.master Aug 5, 2026
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