Skip to content

build: preserve DebugRefs during SSA order repairs#2146

Closed
cpunion wants to merge 2 commits into
xgo-dev:mainfrom
cpunion:codex/dwarf-debugref-return-order
Closed

build: preserve DebugRefs during SSA order repairs#2146
cpunion wants to merge 2 commits into
xgo-dev:mainfrom
cpunion:codex/dwarf-debugref-return-order

Conversation

@cpunion

@cpunion cpunion commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Problem

LLGo repairs Go SSA evaluation order in two places: return values whose storage is mutated by a later call, and assignment targets for single-case select receives. With ssa.GlobalDebug, ssa.DebugRef metadata also uses the affected values. Treating those metadata uses as executable dependencies blocks both otherwise-safe repairs.

That makes enabling DWARF change program behavior:

  • crypto/x509.ParseOID can return a stale OID because its result load stays before the mutating call.
  • A single-case select can evaluate its assignment target before the receive; the acceptance test observes [100 1] instead of [1 100].

Changes

  • move a repaired return load and its ssa.DebugRef users as one stable group after the mutating call
  • move ssa.DebugRef users together with single-case select assignment-target dependencies after the receive
  • continue rejecting either transformation when an executable instruction would observe a moved value too early

The change is confined to the existing SSA order-repair module. It does not alter the loader, DWARF encoding, C ABI lowering, or LLVM optimization pipeline.

Fixes #2122.

Verification

  • synthetic pointer, map, and two-value select regressions with default SSA and ssa.GlobalDebug
  • plain receive and multi-case select non-regressions
  • return-order regressions with default SSA and ssa.GlobalDebug
  • direct crypto/x509.ParseOID SSA regression
  • exact TestSingleCaseSelectReceiveAssignOrder acceptance with -w=false on macOS and Ubuntu arm64
  • crypto/x509 TestOID with -w=false on macOS and Ubuntu arm64
  • full internal/build package on macOS
  • 100% statement coverage for the new select DebugRef grouping helper

@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

❌ Patch coverage is 96.62921% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cl/compile.go 85.24% 6 Missing and 3 partials ⚠️
cl/debug_scope.go 90.90% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@cpunion cpunion changed the title [Based on #2141] build: preserve DebugRefs when reordering returns build: preserve DebugRefs when reordering returns Jul 22, 2026
@cpunion
cpunion force-pushed the codex/dwarf-debugref-return-order branch from 84c513f to d08e0e4 Compare July 22, 2026 09:35
@cpunion cpunion changed the title build: preserve DebugRefs when reordering returns build: preserve DebugRefs during SSA order repairs Jul 22, 2026
@cpunion
cpunion marked this pull request as ready for review July 22, 2026 14:11
@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 SSA DebugRef order-repair changes and their regression coverage. Closing this redundant PR; no code is being merged to main by this action.

@cpunion cpunion closed this Jul 22, 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.

DWARF: preserve crypto/x509 OID.Equal semantics

1 participant