Skip to content

cabi: preserve debug variable homes - #2148

Draft
cpunion wants to merge 1 commit into
xgo-dev:mainfrom
cpunion:codex/dwarf-cabi-metadata
Draft

cabi: preserve debug variable homes#2148
cpunion wants to merge 1 commit into
xgo-dev:mainfrom
cpunion:codex/dwarf-cabi-metadata

Conversation

@cpunion

@cpunion cpunion commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Problem

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

Changes

  • run the same C ABI transformer with and without DWARF;
  • replace uses of the old parameter home so LLVM updates debug records and executable instructions together;
  • restore only setup instructions before the parameter store to the original alloca;
  • verify the setup operand and rewritten dbg.declare/load operands;
  • run the existing large-aggregate probe with DWARF-enabled abi2.

The change stays inside the existing C ABI transformer and adds no debug-specific ABI or target exception.

Dependency update

#2143 and #2215 are merged. This branch is rebased directly onto current main and contains only its C ABI commit.

Verification

  • go test ./internal/cabi ./internal/build;
  • go test ./test/go -run 'TestLargeArrayReturn(AllABIModes|DWARF)$' -count=1;
  • go test -vet=off ./...;
  • git diff --check.

The unscoped go test ./... still hits the same Go toolchain printf analyzer panic in test/go on the merged #2143 baseline; disabling vet verifies the test suite itself.

@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 1401649 to 05b43c0 Compare July 23, 2026 05:08
@cpunion
cpunion force-pushed the codex/dwarf-cabi-metadata branch 4 times, most recently from 1147698 to 375adb4 Compare July 29, 2026 20:31
@cpunion cpunion changed the title [Based on #2143] cabi: preserve debug variable homes [Based on #2215 #2143] cabi: preserve debug variable homes Jul 29, 2026
@cpunion
cpunion marked this pull request as draft August 3, 2026 02:50
@cpunion cpunion changed the title [Based on #2215 #2143] cabi: preserve debug variable homes [Based on #2143] cabi: preserve debug variable homes Aug 4, 2026
@cpunion
cpunion force-pushed the codex/dwarf-cabi-metadata branch from 375adb4 to 1f7a6e9 Compare August 4, 2026 14:11
@cpunion cpunion changed the title [Based on #2143] cabi: preserve debug variable homes cabi: preserve debug variable homes Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

LLGo baseline benchmarks

1f7a6e985682 | workflow run | long-term charts

Program measurements

Platform Workload File size vs base Build vs base Run vs base
Linux cprintf 18456 B +0.0% 320.780 ms +10.2% (worse) 1.282 ms -11.0% (better)
Linux fmtprintf 1829968 B +0.0% 3.023 s +0.2% (worse) 3.139 ms +0.1% (worse)
Linux println 68008 B +0.0% 293.418 ms -3.4% (better) 1.575 ms -16.1% (better)
macOS cprintf 84672 B +0.0% 358.095 ms -6.1% (better) 2.466 ms -14.8% (better)
macOS fmtprintf 1869328 B +0.0% 2.851 s -15.6% (better) 13.664 ms +12.2% (worse)
macOS println 121200 B +0.0% 330.233 ms -0.4% (better) 3.301 ms -14.9% (better)
Core language and compiler benchmarks
Platform Benchmark ns/op vs base
Linux BenchmarkLookupPCRandom 13.360 ns/op +0.6% (worse)
Linux BenchmarkMergeCompilerFlags 151 ns/op +0.5% (worse)
Linux BenchmarkMergeLinkerFlags 96.980 ns/op +2.7% (worse)
Linux BenchmarkChannelBuffered 33.670 ns/op +0.1% (worse)
Linux BenchmarkChannelHandoff 28217 ns/op -3.2% (better)
Linux BenchmarkDefer 48.590 ns/op -0.2% (better)
Linux BenchmarkDirectCall 1.557 ns/op -0.1% (better)
Linux BenchmarkGlobalRead 1.559 ns/op +0.2% (worse)
Linux BenchmarkGlobalWrite 2.478 ns/op -0.0% (better)
Linux BenchmarkGoroutine 33457 ns/op -0.9% (better)
Linux BenchmarkInterfaceCall 8.101 ns/op +0.0% (worse)
Linux BenchmarkRuntimeGetG 2.181 ns/op -0.0% (better)
macOS BenchmarkLookupPCRandom 14.140 ns/op -6.5% (better)
macOS BenchmarkMergeCompilerFlags 128.300 ns/op -19.9% (better)
macOS BenchmarkMergeLinkerFlags 118.900 ns/op +47.6% (worse)
macOS BenchmarkChannelBuffered 27.530 ns/op +8.0% (worse)
macOS BenchmarkChannelHandoff 10283 ns/op +69.0% (worse)
macOS BenchmarkDefer 33.390 ns/op +5.4% (worse)
macOS BenchmarkDirectCall 1.227 ns/op +15.0% (worse)
macOS BenchmarkGlobalRead 1.330 ns/op +3.0% (worse)
macOS BenchmarkGlobalWrite 1.335 ns/op +6.0% (worse)
macOS BenchmarkGoroutine 45387 ns/op +25.8% (worse)
macOS BenchmarkInterfaceCall 5.143 ns/op +7.2% (worse)
macOS BenchmarkRuntimeGetG 2.467 ns/op +11.6% (worse)

Compared with 6670dae3884d measured in the same runner job.

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