[DebugInfo] Salvage more in -O builds

Specifically, improved debug info retention in:
* tryReplaceRedundantInstructionPair,
* splitAggregateLoad,
* TempLValueElimination,
* Mem2Reg,
* 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.

We attempted to add a case to salvageDebugInfo for unchecked_enum_data, but it
caused crashes in Linux CI that we were not able to reproduce.
This commit is contained in:
Aidan Hall
2025-10-23 17:38:25 +01:00
parent e62153187a
commit a95d2979f9
13 changed files with 170 additions and 8 deletions

View File

@@ -102,6 +102,13 @@ public class Instruction : CustomStringConvertible, Hashable {
context.notifyInstructionsChanged()
}
/// Transfer debug info associated with (the result of) this instruction to a
/// new `debug_value` instruction before this instruction is deleted.
public final func salvageDebugInfo(_ context: some MutatingContext) {
BridgedContext.salvageDebugInfo(self.bridged)
context.notifyInstructionsChanged()
}
public var mayTrap: Bool { false }
final public var mayHaveSideEffects: Bool {