Skip to content

Commit 44ed14e

Browse files
authored
Merge pull request swiftlang#36138 from atrick/comment-deleteinst
2 parents 4d593f4 + 717e1a1 commit 44ed14e

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

include/swift/SILOptimizer/Utils/InstOptUtils.h

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ class InstructionDeleter {
9393

9494
/// If the instruction \p inst is dead, delete it immediately and record
9595
/// its operands so that they can be cleaned up later.
96+
///
97+
/// \p callback is called on each deleted instruction before deleting any
98+
/// instructions. This way, the SIL is valid in the callback. However, the
99+
/// callback cannot be used to update instruction iterators since other
100+
/// instructions to be deleted remain in the instruction list.
96101
void deleteIfDead(
97102
SILInstruction *inst,
98103
llvm::function_ref<void(SILInstruction *)> callback =
@@ -110,8 +115,10 @@ class InstructionDeleter {
110115
/// \pre the instruction to be deleted must not have any use other than
111116
/// incidental uses.
112117
///
113-
/// \param callback a callback called whenever an instruction
114-
/// is deleted.
118+
/// \p callback is called on each deleted instruction before deleting any
119+
/// instructions. This way, the SIL is valid in the callback. However, the
120+
/// callback cannot be used to update instruction iterators since other
121+
/// instructions to be deleted remain in the instruction list.
115122
void forceDeleteAndFixLifetimes(
116123
SILInstruction *inst,
117124
llvm::function_ref<void(SILInstruction *)> callback =
@@ -130,8 +137,10 @@ class InstructionDeleter {
130137
/// \pre the instruction to be deleted must not have any use other than
131138
/// incidental uses.
132139
///
133-
/// \param callback a callback called whenever an instruction
134-
/// is deleted.
140+
/// \p callback is called on each deleted instruction before deleting any
141+
/// instructions. This way, the SIL is valid in the callback. However, the
142+
/// callback cannot be used to update instruction iterators since other
143+
/// instructions to be deleted remain in the instruction list.
135144
void forceDelete(
136145
SILInstruction *inst,
137146
llvm::function_ref<void(SILInstruction *)> callback =
@@ -145,7 +154,10 @@ class InstructionDeleter {
145154
/// function body in an inconsistent state, it needs to be made consistent
146155
/// before this method is invoked.
147156
///
148-
/// \param callback a callback called whenever an instruction is deleted.
157+
/// \p callback is called on each deleted instruction before deleting any
158+
/// instructions. This way, the SIL is valid in the callback. However, the
159+
/// callback cannot be used to update instruction iterators since other
160+
/// instructions to be deleted remain in the instruction list.
149161
void
150162
cleanUpDeadInstructions(llvm::function_ref<void(SILInstruction *)> callback =
151163
[](SILInstruction *) {});
@@ -178,7 +190,10 @@ class InstructionDeleter {
178190
/// \pre the SIL function containing the instruction is assumed to be
179191
/// consistent, i.e., does not have under or over releases.
180192
///
181-
/// \param callback a callback called whenever an instruction is deleted.
193+
/// \p callback is called on each deleted instruction before deleting any
194+
/// instructions. This way, the SIL is valid in the callback. However, the
195+
/// callback cannot be used to update instruction iterators since other
196+
/// instructions to be deleted remain in the instruction list.
182197
void eliminateDeadInstruction(
183198
SILInstruction *inst, llvm::function_ref<void(SILInstruction *)> callback =
184199
[](SILInstruction *) {});

0 commit comments

Comments
 (0)