Skip to content

Conversation

@aidan-hall
Copy link
Contributor

@aidan-hall aidan-hall commented Oct 31, 2025

Depends on #85237: Ignore b353bb3 in this PR.

@aidan-hall aidan-hall self-assigned this Oct 31, 2025
@aidan-hall aidan-hall changed the title Fixing debug info rebase Retain more debug info in optimized builds Oct 31, 2025
@aidan-hall aidan-hall force-pushed the fixing-debug-info-rebase branch 3 times, most recently from d1aece3 to 53b21e3 Compare November 5, 2025 16:08
@aidan-hall aidan-hall marked this pull request as ready for review November 5, 2025 16:37
Copy link
Contributor

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!

@aidan-hall aidan-hall force-pushed the fixing-debug-info-rebase branch 3 times, most recently from 3faa1e9 to fb593f4 Compare November 5, 2025 18:08
}
}

first.salvageDebugInfo(self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why this is needed.
The following replace calls erase(instruction:) which itself calls salvageDebugInfo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The replace is for the second instruction, while this salvage is for the first instruction. It should only be necessary in optimized builds, so I'm changing this code. The test for this case is DebugInfo/simplify_struct_extract.sil.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay

@aidan-hall aidan-hall force-pushed the fixing-debug-info-rebase branch 3 times, most recently from 118f114 to af515fd Compare November 10, 2025 11:51
if !preserveDebugInfo {
first.salvageDebugInfo(self)
}
erase(instructionIncludingDebugUses: first)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eeckstein erase(instructionIncludingDebugUses:) calls erase(instructionIncludingAllUsers:), which seems to have a postcondition that the operands of the erased instruction have no users. I'm not sure if that's relevant here though, since replacement is informally assumed to be one of first's operands, and this function replaces uses of second with replacement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine

Copy link
Contributor Author

@aidan-hall aidan-hall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one point of confusion

@aidan-hall
Copy link
Contributor Author

@swift-ci smoke test

1 similar comment
@aidan-hall
Copy link
Contributor Author

@swift-ci smoke test

Specifically, improved debug info retention in:
* tryReplaceRedundantInstructionPair,
* splitAggregateLoad,
* TempLValueElimination,
* Mem2Reg,
* salvageDebugInfo (added case for unchecked_enum_data instructions),
* ConstantFolding.

The changes to Mem2Reg allow debug info to be retained in the case tested by
self-nostorage.swift in -O builds, so we have just enabled -O in that file
instead of writing a new test for it.
@aidan-hall aidan-hall force-pushed the fixing-debug-info-rebase branch from af515fd to 9240379 Compare November 11, 2025 18:15
@aidan-hall
Copy link
Contributor Author

macOS & Windows passed, but Linux had a crash in my new salvageDebugInfo case. I smell a subtle incompatibility between libstdc++ and libc++ std::optional, so I've adjusted how I'm using it to be consistent with the other cases in the same function.
@swift-ci smoke test

@aidan-hall
Copy link
Contributor Author

@swift-ci smoke test linux

@aidan-hall
Copy link
Contributor Author

@swift-ci smoke test macos

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.

3 participants