Skip to content

Commit b856e3d

Browse files
committed
Revert "Optimizer: make salvageDebugInfo optional when deleting instructions"
This reverts commit 85a49dc.
1 parent 387f700 commit b856e3d

File tree

7 files changed

+19
-35
lines changed

7 files changed

+19
-35
lines changed

SwiftCompilerSources/Sources/Optimizer/PassManager/Context.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,7 @@ extension MutatingContext {
140140
return _bridged.createBlockAfter(block.bridged).block
141141
}
142142

143-
/// Removes and deletes `instruction`.
144-
/// If `salvageDebugInfo` is true, compensating `debug_value` instructions are inserted for certain
145-
/// kind of instructions.
146-
func erase(instruction: Instruction, salvageDebugInfo: Bool = true) {
143+
func erase(instruction: Instruction) {
147144
if !instruction.isInStaticInitializer {
148145
verifyIsTransforming(function: instruction.parentFunction)
149146
}
@@ -155,7 +152,7 @@ extension MutatingContext {
155152
}
156153
notifyInstructionsChanged()
157154

158-
_bridged.eraseInstruction(instruction.bridged, salvageDebugInfo)
155+
_bridged.eraseInstruction(instruction.bridged)
159156
}
160157

161158
func erase(instructionIncludingAllUsers inst: Instruction) {
@@ -167,9 +164,7 @@ extension MutatingContext {
167164
erase(instructionIncludingAllUsers: use.instruction)
168165
}
169166
}
170-
// We rely that after deleting the instruction its operands have no users.
171-
// Therefore `salvageDebugInfo` must be turned off because we cannot insert debug_value instructions.
172-
erase(instruction: inst, salvageDebugInfo: false)
167+
erase(instruction: inst)
173168
}
174169

175170
func erase<S: Sequence>(instructions: S) where S.Element: Instruction {

include/swift/SIL/SILInstructionWorklist.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,9 @@ class SILInstructionWorklist : SILInstructionWorklistBase {
302302
// method to delete the given instruction.
303303
void eraseInstFromFunction(SILInstruction &instruction,
304304
SILBasicBlock::iterator &iterator,
305-
bool addOperandsToWorklist = true,
306-
bool salvageDebugInfo = true) {
307-
if (salvageDebugInfo) {
308-
// Try to salvage debug info first.
309-
swift::salvageDebugInfo(&instruction);
310-
}
305+
bool addOperandsToWorklist = true) {
306+
// Try to salvage debug info first.
307+
swift::salvageDebugInfo(&instruction);
311308
// Then delete old debug users.
312309
for (auto result : instruction.getResults()) {
313310
while (!result->use_empty()) {
@@ -326,11 +323,9 @@ class SILInstructionWorklist : SILInstructionWorklistBase {
326323
}
327324

328325
void eraseInstFromFunction(SILInstruction &instruction,
329-
bool addOperandsToWorklist = true,
330-
bool salvageDebugInfo = true) {
326+
bool addOperandsToWorklist = true) {
331327
SILBasicBlock::iterator nullIter;
332-
return eraseInstFromFunction(instruction, nullIter, addOperandsToWorklist,
333-
salvageDebugInfo);
328+
return eraseInstFromFunction(instruction, nullIter, addOperandsToWorklist);
334329
}
335330

336331
void eraseSingleInstFromFunction(SILInstruction &instruction,

include/swift/SILOptimizer/OptimizerBridging.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ struct BridgedPassContext {
234234
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedBasicBlock splitBlockAfter(BridgedInstruction bridgedInst) const;
235235
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedBasicBlock createBlockAfter(BridgedBasicBlock bridgedBlock) const;
236236
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedBasicBlock appendBlock(BridgedFunction bridgedFunction) const;
237-
BRIDGED_INLINE void eraseInstruction(BridgedInstruction inst, bool salvageDebugInfo) const;
237+
BRIDGED_INLINE void eraseInstruction(BridgedInstruction inst) const;
238238
BRIDGED_INLINE void eraseBlock(BridgedBasicBlock block) const;
239239
static BRIDGED_INLINE void moveInstructionBefore(BridgedInstruction inst, BridgedInstruction beforeInst);
240240
bool tryOptimizeApplyOfPartialApply(BridgedInstruction closure) const;

include/swift/SILOptimizer/OptimizerBridgingImpl.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "swift/SILOptimizer/OptimizerBridging.h"
2828
#include "swift/SILOptimizer/PassManager/PassManager.h"
2929
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
30-
#include "swift/SILOptimizer/Utils/DebugOptUtils.h"
3130

3231
SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
3332

@@ -254,8 +253,8 @@ BridgedBasicBlock BridgedPassContext::appendBlock(BridgedFunction bridgedFunctio
254253
return {bridgedFunction.getFunction()->createBasicBlock()};
255254
}
256255

257-
void BridgedPassContext::eraseInstruction(BridgedInstruction inst, bool salvageDebugInfo) const {
258-
invocation->eraseInstruction(inst.unbridged(), salvageDebugInfo);
256+
void BridgedPassContext::eraseInstruction(BridgedInstruction inst) const {
257+
invocation->eraseInstruction(inst.unbridged());
259258
}
260259

261260
void BridgedPassContext::eraseBlock(BridgedBasicBlock block) const {

include/swift/SILOptimizer/PassManager/PassManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class SwiftPassInvocation {
138138
void freeOperandSet(OperandSet *set);
139139

140140
/// The top-level API to erase an instruction, called from the Swift pass.
141-
void eraseInstruction(SILInstruction *inst, bool salvageDebugInfo);
141+
void eraseInstruction(SILInstruction *inst);
142142

143143
/// Called by the pass when changes are made to the SIL.
144144
void notifyChanges(SILAnalysis::InvalidationKind invalidationKind);

lib/SILOptimizer/SILCombiner/SILCombine.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -694,13 +694,11 @@ SILTransform *swift::createSILCombine() {
694694
// SwiftFunctionPassContext
695695
//===----------------------------------------------------------------------===//
696696

697-
void SwiftPassInvocation::eraseInstruction(SILInstruction *inst, bool salvageDebugInfo) {
697+
void SwiftPassInvocation::eraseInstruction(SILInstruction *inst) {
698698
if (silCombiner) {
699-
silCombiner->eraseInstFromFunction(*inst, /*addOperandsToWorklist=*/ true, salvageDebugInfo);
699+
silCombiner->eraseInstFromFunction(*inst);
700700
} else {
701-
if (salvageDebugInfo) {
702-
swift::salvageDebugInfo(inst);
703-
}
701+
swift::salvageDebugInfo(inst);
704702
if (inst->isStaticInitializerInst()) {
705703
inst->getParent()->erase(inst, *getPassManager()->getModule());
706704
} else {

lib/SILOptimizer/SILCombiner/SILCombiner.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,8 @@ class SILCombiner :
220220
// by this method.
221221
SILInstruction *eraseInstFromFunction(SILInstruction &I,
222222
SILBasicBlock::iterator &InstIter,
223-
bool AddOperandsToWorklist = true,
224-
bool salvageDebugInfo = true) {
225-
Worklist.eraseInstFromFunction(I, InstIter, AddOperandsToWorklist,
226-
salvageDebugInfo);
223+
bool AddOperandsToWorklist = true) {
224+
Worklist.eraseInstFromFunction(I, InstIter, AddOperandsToWorklist);
227225
MadeChange = true;
228226
// Dummy return, so the caller doesn't need to explicitly return nullptr.
229227
return nullptr;
@@ -234,10 +232,9 @@ class SILCombiner :
234232
void eraseInstIncludingUsers(SILInstruction *inst);
235233

236234
SILInstruction *eraseInstFromFunction(SILInstruction &I,
237-
bool AddOperandsToWorklist = true,
238-
bool salvageDebugInfo = true) {
235+
bool AddOperandsToWorklist = true) {
239236
SILBasicBlock::iterator nullIter;
240-
return eraseInstFromFunction(I, nullIter, AddOperandsToWorklist, salvageDebugInfo);
237+
return eraseInstFromFunction(I, nullIter, AddOperandsToWorklist);
241238
}
242239

243240
void addInitialGroup(ArrayRef<SILInstruction *> List) {

0 commit comments

Comments
 (0)