Skip to content

[Based on #2143] cabi: preserve debug variable homes#2148

Open
cpunion wants to merge 8 commits into
xgo-dev:mainfrom
cpunion:codex/dwarf-cabi-metadata
Open

[Based on #2143] cabi: preserve debug variable homes#2148
cpunion wants to merge 8 commits into
xgo-dev:mainfrom
cpunion:codex/dwarf-cabi-metadata

Conversation

@cpunion

@cpunion cpunion commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Depends on #2143.

Problem

LLGo currently disables optimized C ABI lowering whenever DWARF is enabled. The lowering replaces a source parameter's stack home with its ABI storage, but its selective operand rewrite does not update LLVM debug records. Enabling the lowering as-is can therefore leave dbg.declare attached to stale storage.

The dependency on #2143 is required by the end-to-end path. On latest main, the focused operand-rewrite test passes, but the real abi2 + DWARF large-aggregate test crashes while LLVM emits the object. With #2143's DWARF-safe optimization pipeline, the same test completes on both supported validation platforms.

Changes

  • run the same C ABI transformer with and without DWARF
  • replace all uses of the old parameter home so LLVM updates debug records as well as executable instructions
  • restore only setup instructions before the parameter store to the original alloca
  • add a focused LLVM-level regression that verifies both the preserved setup operand and the rewritten dbg.declare/load operands
  • run the existing large-aggregate test/go probe in DWARF-enabled abi2 mode

The change remains inside the existing C ABI transformer; no debug-specific ABI representation or target exception is introduced.

Verification

  • macOS arm64: full internal/cabi and internal/build package tests; real TestLargeArrayReturnDWARF passes in 15.10s
  • Ubuntu arm64: focused debug-record regression and real TestLargeArrayReturnDWARF pass in 15.31s
  • direct-main dependency check: the focused unit test passes, while the real acceptance test reproduces the LLVM object-emission crash

Ubuntu validation used 2 CPUs, an 8 GiB memory limit with no swap, and 512 PIDs.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cpunion cpunion changed the title [Based on #2141 #2143] cabi: preserve debug variable homes [Based on #2143] cabi: preserve debug variable homes Jul 22, 2026
@cpunion
cpunion force-pushed the codex/dwarf-cabi-metadata branch from b2266d8 to 1401649 Compare July 22, 2026 10:11
@cpunion
cpunion marked this pull request as ready for review July 22, 2026 14:12
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@cpunion
cpunion force-pushed the codex/dwarf-cabi-metadata branch from 05b43c0 to 688e810 Compare July 24, 2026 08:14
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