Skip to content

[DebugInfo] Salvage ref_tail_addr#90022

Open
Snowy1803 wants to merge 6 commits into
swiftlang:mainfrom
Snowy1803:salvage-ref-tail-addr
Open

[DebugInfo] Salvage ref_tail_addr#90022
Snowy1803 wants to merge 6 commits into
swiftlang:mainfrom
Snowy1803:salvage-ref-tail-addr

Conversation

@Snowy1803

@Snowy1803 Snowy1803 commented Jun 17, 2026

Copy link
Copy Markdown
Member

Based on #89692

Accounts for 1.6% of missing salvages in the Source Compatibility Test Suite.

Decreases lost variables in stdlib by 0.2% and increases variables with location at DWARF level by 0.02%.

Tail elements are used by arrays to store values inline, so this is necessary for code making heavy use of arrays.

@Snowy1803

Copy link
Copy Markdown
Member Author

@swift-ci test

As mentioned in the comment, the DIExpr is present for easily moving
debug info. The same variable with different DIExpr still refer to the
same variable.

The only pass using SILDebugVariable as a DenseMap key, is only run at
-Onone, so its handling of fragments isn't needed. The fragment handling
didn't even work, as the DIExpr didn't have an equality operator, so
only its existence (via the bool() operator) was compared, not its
content.
If a debug_value is being salvaged through a lifetime-ending
instruction, the salvaged operand will be invalid and cause an
ownership error. In that case, hoist the debug_value to be where
the salvaged instruction was.

If a debug_value for the same variable exists between both locations,
the hoist is not legal: kill the operand instead.
The lifetime of guaranteed values is tied to the original borrow, not
to the operand which might be a projection.
@Snowy1803 Snowy1803 force-pushed the salvage-ref-tail-addr branch from 2cf8253 to cceb87e Compare June 18, 2026 15:33
@Snowy1803

Copy link
Copy Markdown
Member Author

@swift-ci test

@Snowy1803

Copy link
Copy Markdown
Member Author

@swift-ci test macOS platform

3 similar comments
@Snowy1803

Copy link
Copy Markdown
Member Author

@swift-ci test macOS platform

@Snowy1803

Copy link
Copy Markdown
Member Author

@swift-ci test macOS platform

@Snowy1803

Copy link
Copy Markdown
Member Author

@swift-ci test macOS platform

The value being borrowed has always a longer lifetime than the borrow,
so this allows more debug values to be successfully salvaged rather
than killed if the borrow ends before the debug_value.
Accounts for 1.6% of missing salvages in the Source Compatibility Test
Suite.
@Snowy1803 Snowy1803 force-pushed the salvage-ref-tail-addr branch from cceb87e to b9579f0 Compare June 18, 2026 17:15
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