Skip to content

[6.4] [DebugInfo] Fix consistency of op_deref handling#89259

Open
Snowy1803 wants to merge 7 commits into
swiftlang:release/6.4.xfrom
Snowy1803:6.4-deref-refactor
Open

[6.4] [DebugInfo] Fix consistency of op_deref handling#89259
Snowy1803 wants to merge 7 commits into
swiftlang:release/6.4.xfrom
Snowy1803:6.4-deref-refactor

Conversation

@Snowy1803
Copy link
Copy Markdown
Member

Snowy1803 added 7 commits May 19, 2026 16:42
SIL-based debug info does not support debug variables. It is limited to
line tables at the IRGen level. Keeping alloc_stack variables but not
debug_values is inconsistent.

(cherry picked from commit a95a3f9)
This deprecates the use of DIExpr on alloc_stack. When varinfo is present
on an alloc_stack, it represents the whole variable. Otherwise, debug_value
should be used.

(cherry picked from commit c3f339e)
A VarInfo within an AllocStackInst should only be used when the variable
is fully in the stack slot. Otherwise, a debug_value should be used.

(cherry picked from commit 5c3a9a8)
For consistency within SIL, we want to keep the information that the value
associated with an alloc_stack needs to be dereferenced to have access to
the variables value.

This should simplify passes that might conditionally remove an op_deref:
for address types, there should always be an op_deref.

IRGen then internally strips the op_deref so that when a dbg_declare is
created, it will not have an additional op_deref.

This commit changes SIL but should not affect the LLVM IR of a program.

(cherry picked from commit 3afc5f0)
The VarInfo for an alloc_stack will always have an op_deref, so that they can
get copied along when the VarInfo is moved to a debug_value. This op_deref is
not printed by the SILPrinter.

This commit also updates uses of AllocStackInst's getVarInfo to strip this
op_deref at places where it is not needed, and uses of createDebugValueAddr
where the extra op_deref is no longer needed.

The only change at the IR level is for undef values that now have a DW_OP_deref
for move-only values.

This fixes most of the inconsitencies with op_deref at the SIL level. All
debug_values with addresses should always have an op_deref.

Assisted-by: Claude Opus 4.6 (Updated tests)
(cherry picked from commit 855bc12)
All SIL tests now use op_deref correctly on debug_values on address
types, such as alloc_stack. All tests are now conforming to the new
model of always using op_deref for addresses.

Assisted-by: Claude
(cherry picked from commit e25938e)
…h op_deref

Instead of using a single DirectValue/IndirectValue enum with duplicate values
for coro context, indirect values are now represented with an extra op_deref
throughout.

This makes the code simpler: Coro context is now a boolean throughout, and
the intent behind indirection is clearer. It also cleanly supports multiple
layers of indirection: if two consecutive paths set the indirection kind to
IndirectValue, it would only insert one DW_OP_deref instead of two.

This fixes the move_function_dbginfo.swift test file with the deref behaviour
(rdar://176552243). All changed test cases have been tested manually in LLDB
to make sure it is the correct behaviour.

Assisted-by: Claude
(cherry picked from commit f5bfa83)
@Snowy1803 Snowy1803 requested a review from a team as a code owner May 19, 2026 15:52
@Snowy1803
Copy link
Copy Markdown
Member Author

@swift-ci test

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