Skip to content

debug: preserve defer locations under full LTO#2144

Closed
cpunion wants to merge 1 commit into
xgo-dev:mainfrom
cpunion:codex/dwarf-lto-debugloc
Closed

debug: preserve defer locations under full LTO#2144
cpunion wants to merge 1 commit into
xgo-dev:mainfrom
cpunion:codex/dwarf-lto-debugloc

Conversation

@cpunion

@cpunion cpunion commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Problem

Conditional defer lowering splits the function entry block with a fresh LLVM builder. In a function carrying DWARF, that builder does not inherit the Go source location that triggered defer setup, so synthesized calls such as GetThreadDefer, AllocU, SetThreadDefer, and Rethrow have no !dbg attachment.

Normal native links may accept that IR, but full LTO verifies the combined debug-bearing module and aborts with inlinable function call in a function with debug info must have a !dbg location.

Changes

  • pass the source builder into defer-entry splitting
  • copy its current DebugLoc to the synthetic builder when the function has debug metadata
  • leave non-debug defer lowering unchanged
  • add focused location-inheritance coverage
  • add separate DWARF acceptance tests for built-in full LTO and the optional LTO pass plugin

The LTO tests disable LLGo's package cache so #2119's cold/warm metadata issue cannot hide or reintroduce this verifier failure.

Fixes #2118.

Verification

  • built-in full LTO DWARF fixture on macOS and Ubuntu arm64
  • pass-plugin full LTO DWARF fixture on Ubuntu arm64
  • full ssa tests on macOS
  • standards-based DWARF matrix on macOS and Ubuntu arm64
  • changed helper coverage: 100%

Ubuntu validation used 2 CPUs, a 15 GiB memory limit, 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 21, 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 force-pushed the codex/dwarf-lto-debugloc branch from e631213 to 577cda3 Compare July 22, 2026 08:25
@cpunion cpunion changed the title [Based on #2141] debug: preserve defer locations under full LTO debug: preserve defer locations under full LTO Jul 22, 2026
@cpunion
cpunion marked this pull request as ready for review July 22, 2026 09:19
@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 commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

Consolidated into #2143, which now contains the defer-call debug-location preservation and its LTO regression coverage. Closing this redundant PR; no code is being merged to main by this action.

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.

DWARF: emit verifier-valid call locations under LTO

1 participant