[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

@@ -1534,6 +1534,7 @@ struct BridgedContext {
BRIDGED_INLINE void eraseBlock(BridgedBasicBlock block) const;
static BRIDGED_INLINE void moveInstructionBefore(BridgedInstruction inst, BridgedInstruction beforeInst);
static BRIDGED_INLINE void copyInstructionBefore(BridgedInstruction inst, BridgedInstruction beforeInst);
static BRIDGED_INLINE void salvageDebugInfo(BridgedInstruction inst);
// SSAUpdater

View File

@@ -41,6 +41,7 @@
#include "swift/SIL/SILVTable.h"
#include "swift/SIL/SILWitnessTable.h"
#include "swift/SILOptimizer/Utils/ConstExpr.h"
#include "swift/SILOptimizer/Utils/DebugOptUtils.h"
#include "swift/SIL/SILConstants.h"
#include <stdbool.h>
#include <stddef.h>
@@ -3129,6 +3130,10 @@ void BridgedContext::copyInstructionBefore(BridgedInstruction inst, BridgedInstr
inst.unbridged()->clone(beforeInst.unbridged());
}
void BridgedContext::salvageDebugInfo(BridgedInstruction inst) {
swift::salvageDebugInfo(inst.unbridged());
}
OptionalBridgedFunction BridgedContext::lookupStdlibFunction(BridgedStringRef name) const {
return {context->lookupStdlibFunction(name.unbridged())};
}