Skip to content

Commit b353bb3

Browse files
committed
DebugUtils: Remove eraseFromParentWithDebugInsts
There is another near-identical function in DebugOptUtils.h that can be used everywhere this function is used, and offers more flexibility in its callback interface.
1 parent a8cef44 commit b353bb3

File tree

3 files changed

+2
-41
lines changed

3 files changed

+2
-41
lines changed

include/swift/SIL/DebugUtils.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -204,45 +204,6 @@ inline Operand *getAnyDebugUse(SILValue value) {
204204
return *ii;
205205
}
206206

207-
/// Erases the instruction \p I from it's parent block and deletes it, including
208-
/// all debug instructions which use \p I.
209-
/// Precondition: The instruction may only have debug instructions as uses.
210-
/// If the iterator \p InstIter references any deleted instruction, it is
211-
/// incremented.
212-
///
213-
/// \p callBack will be invoked before each instruction is deleted. \p callBack
214-
/// is not responsible for deleting the instruction because this utility
215-
/// unconditionally deletes the \p I and its debug users.
216-
///
217-
/// Returns an iterator to the next non-deleted instruction after \p I.
218-
inline SILBasicBlock::iterator eraseFromParentWithDebugInsts(
219-
SILInstruction *I, llvm::function_ref<void(SILInstruction *)> callBack =
220-
[](SILInstruction *) {}) {
221-
222-
auto nextII = std::next(I->getIterator());
223-
224-
auto results = I->getResults();
225-
226-
bool foundAny;
227-
do {
228-
foundAny = false;
229-
for (auto result : results) {
230-
while (!result->use_empty()) {
231-
foundAny = true;
232-
auto *User = result->use_begin()->getUser();
233-
assert(User->isDebugInstruction());
234-
if (nextII == User->getIterator())
235-
nextII++;
236-
callBack(User);
237-
User->eraseFromParent();
238-
}
239-
}
240-
} while (foundAny);
241-
242-
I->eraseFromParent();
243-
return nextII;
244-
}
245-
246207
/// Return true if the def-use graph rooted at \p V contains any non-debug,
247208
/// non-trivial users.
248209
bool hasNonTrivialNonDebugTransitiveUsers(

lib/SILOptimizer/Transforms/CSE.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#define DEBUG_TYPE "sil-cse"
1919
#include "swift/Basic/Assertions.h"
20-
#include "swift/SIL/DebugUtils.h"
2120
#include "swift/SIL/Dominance.h"
2221
#include "swift/SIL/InstructionUtils.h"
2322
#include "swift/SIL/NodeBits.h"
@@ -34,6 +33,7 @@
3433
#include "swift/SILOptimizer/PassManager/Passes.h"
3534
#include "swift/SILOptimizer/PassManager/Transforms.h"
3635
#include "swift/SILOptimizer/Utils/BasicBlockOptUtils.h"
36+
#include "swift/SILOptimizer/Utils/DebugOptUtils.h"
3737
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
3838
#include "swift/SILOptimizer/Utils/OwnershipOptUtils.h"
3939
#include "swift/SILOptimizer/Utils/SILInliner.h"

lib/SILOptimizer/Transforms/SimplifyCFG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "swift/AST/Module.h"
3535
#include "swift/Basic/Assertions.h"
3636
#include "swift/SIL/BasicBlockDatastructures.h"
37-
#include "swift/SIL/DebugUtils.h"
3837
#include "swift/SIL/Dominance.h"
3938
#include "swift/SIL/InstructionUtils.h"
4039
#include "swift/SIL/Projection.h"
@@ -52,6 +51,7 @@
5251
#include "swift/SILOptimizer/Utils/BasicBlockOptUtils.h"
5352
#include "swift/SILOptimizer/Utils/CFGOptUtils.h"
5453
#include "swift/SILOptimizer/Utils/CastOptimizer.h"
54+
#include "swift/SILOptimizer/Utils/DebugOptUtils.h"
5555
#include "swift/SILOptimizer/Utils/InstOptUtils.h"
5656
#include "swift/SILOptimizer/Utils/OwnershipOptUtils.h"
5757
#include "swift/SILOptimizer/Utils/SILInliner.h"

0 commit comments

Comments
 (0)