Skip to content

cmd/compile: expand LLVM nil checks after IR construction - #38

Merged
zhouguangyuan0718 merged 1 commit into
go1.27.masterfrom
codex/llvm-nilcheck-intrinsic-expand
Aug 2, 2026
Merged

cmd/compile: expand LLVM nil checks after IR construction#38
zhouguangyuan0718 merged 1 commit into
go1.27.masterfrom
codex/llvm-nilcheck-intrinsic-expand

Conversation

@zhouguangyuan0718

@zhouguangyuan0718 zhouguangyuan0718 commented Aug 2, 2026

Copy link
Copy Markdown

Summary

  • emit llvm.goallc.nilcheck as a temporary semantic marker during SSA-to-LLVM value lowering
  • finish the original LLVM CFG and populate PHI incoming edges through the normal FinishPhi() path
  • expand every marker afterward into an explicit null branch and ABIInternal runtime.panicmem call
  • repair only the affected successor PHI predecessors through Value.ReplaceIncomingBlock
  • remove the first-pass BlockEnds CFG bypass entirely
  • fail closed if the marker declaration/type/calls are malformed or if any marker survives expansion

The marker is deleted before LLVM verification, optimization, statepoint rewriting, or IR emission.

Uses merged goallc/go-llvm#5 at v0.0.0-20260802014221-e0a85f0a18bc (master@e0a85f0a18bc).

Validation

  • src/make.bash
  • go mod verify; go list -mod=vendor github.com/goallc/go-llvm
  • go test -tags="llvm23 dynamicllvm" -count=1 cmd/compile/internal/ssa cmd/llvmtoolexec
  • LLVM codegen whitelist 49/49
  • LLVM runtime whitelist 46/46
  • focused nilcheck codegen, runtime/recover, and GoObj tests
  • goallc/go-llvm full tests
  • plugin CTest 47/47
  • final IR and statepoint IR contain no llvm.goallc.nilcheck
  • opt -load-pass-plugin=... -passes=verify
  • llc -load-pass-plugin=... -verify-machineinstrs -filetype=obj
  • objview confirms frameful ordinary panicmem safepoint map and separate stack-growth map
  • gofmt; go mod tidy; go mod vendor; git diff --check

Existing boundary

The aggregate Test/LLVM command still reports the pre-existing abi-differential/mixedABI pointer-map count mismatch. The nilcheck fixture and changed lowering do not participate in that ABI case; codegen, runtime, alloca/statepoint, and fail-closed groups otherwise pass.

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