[6.4] [DebugInfo] Fix consistency of op_deref handling#89259
Open
Snowy1803 wants to merge 7 commits into
Open
Conversation
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)
Member
Author
|
@swift-ci test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Collection of fixes to the consistency of the usage of op_deref within SIL. All alloc_stacks and debug_values with address types use op_deref, and IRGen uses op_deref for indirection.
Only updates SIL-level debug values. The only impact on generated LLVM IR is a bug fix for wrong debug info.
Fixes wrong deref behaviour in rdar://176552243
[DebugInfo] Invalidate alloc_stack varinfo in sil-based debuginfo #88831
[DebugInfo] Move fragments from alloc_stack to debug_value in SILSROA #88838
[DebugInfo] Remove DIExpr from AllocStackInst #88845
[DebugInfo] Add op_deref to all alloc_stacks and debug_value pointing to alloc_stacks #88870
[IRGen] [DebugInfo] Replace IndirectionKind with op_deref #88962
Low, only touches SIL-level debug values
All existing tests have been updated.
@adrian-prantl