Skip to content

fix(ssa): preserve debug locations in synthetic builders - #245

Closed
cpunion wants to merge 1 commit into
codex/wasm-r4-main-base-20260907from
codex/fix-synthetic-debug-location-20260908
Closed

cpunion wants to merge 1 commit into
codex/wasm-r4-main-base-20260907from
codex/fix-synthetic-debug-location-20260908

Conversation

@cpunion

@cpunion cpunion commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Problem

Synthetic builders may not have a current source location even when their function has a DISubprogram. The LLVM binding explicitly requires a location to have been set before calling GetCurrentDebugLocation; deferInitBuilder violated that precondition and crashed in LLVMGoGetCurrentDebugLocation during CI.

Other synthetic calls in debug-enabled functions failed LLVM verification: an inlinable call must have a !dbg location. R4's macOS LTO checks exposed this for os.(*root).decref. The affected code exists on upstream main be23e488a; this PR contains no R4 runtime changes.

Fix

  • Track explicitly assigned source locations in the Go builder instead of reading a potentially unset LLVM location.
  • Initialize synthetic builders in debug-enabled functions with a line-zero function location, denoting generated code without inventing a source line.
  • Preserve the originating source location for generated defer setup when available.

Validation

  • Full SSA tests pass in R4; focused tests also pass on this main-based branch.
  • Regressions cover builders created before/after debug initialization, debug-disabled functions, exact source-location inheritance, and LLVM verification of an inlinable synthetic call.
  • Actual R4 native fixture tests built with debug info pass.
  • The three failing macOS LTO cases advance past the original LLVM verifier error locally. Final local linking is blocked by this machine's LLVM 22 plugin / LLD 23 mismatch; this is not counted as an end-to-end pass. Matching LLVM 22 fork CI remains required.

No debug-info disabling or LLVM dependency replacement is used. Keep this draft until CI verification completes.

@cpunion

cpunion commented Sep 8, 2026

Copy link
Copy Markdown
Owner Author

Moved to xgo-dev#2529 as requested. All 8 remaining fork workflow runs are cancelled; verification continues in the upstream contribution PR. Keeping the source branch for that PR and the dependent stack-slot fix.

@cpunion cpunion closed this Sep 8, 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