@@ -53,21 +53,6 @@ static SILValue stripCopiesAndBorrows(SILValue v) {
53
53
return v;
54
54
}
55
55
56
- // / If \p applySite is a terminator then pass the first instruction of each
57
- // / successor to fun. Otherwise, pass std::next(applySite).
58
- static void
59
- insertAfterApply (SILInstruction *applySite,
60
- llvm::function_ref<void (SILBasicBlock::iterator)> &&fun) {
61
- auto *ti = dyn_cast<TermInst>(applySite);
62
- if (!ti) {
63
- return fun (std::next (applySite->getIterator ()));
64
- }
65
-
66
- for (auto *succBlocks : ti->getSuccessorBlocks ()) {
67
- fun (succBlocks->begin ());
68
- }
69
- }
70
-
71
56
// / Fixup reference counts after inlining a function call (which is a no-op
72
57
// / unless the function is a thick function).
73
58
// /
@@ -174,13 +159,12 @@ static void fixupReferenceCounts(
174
159
// insert a destroy after the apply since the leak will just cover the
175
160
// other path.
176
161
if (!error.getFoundOverConsume ()) {
177
- insertAfterApply (
178
- applySite.getInstruction (), [&](SILBasicBlock::iterator iter) {
179
- if (hasOwnership) {
180
- SILBuilderWithScope (iter).createEndBorrow (loc, argument);
181
- }
182
- SILBuilderWithScope (iter).emitDestroyValueOperation (loc, copy);
183
- });
162
+ applySite.insertAfter ([&](SILBasicBlock::iterator iter) {
163
+ if (hasOwnership) {
164
+ SILBuilderWithScope (iter).createEndBorrow (loc, argument);
165
+ }
166
+ SILBuilderWithScope (iter).emitDestroyValueOperation (loc, copy);
167
+ });
184
168
}
185
169
v = argument;
186
170
break ;
@@ -215,10 +199,9 @@ static void fixupReferenceCounts(
215
199
}
216
200
}
217
201
218
- insertAfterApply (
219
- applySite.getInstruction (), [&](SILBasicBlock::iterator iter) {
220
- SILBuilderWithScope (iter).emitDestroyValueOperation (loc, v);
221
- });
202
+ applySite.insertAfter ([&](SILBasicBlock::iterator iter) {
203
+ SILBuilderWithScope (iter).emitDestroyValueOperation (loc, v);
204
+ });
222
205
break ;
223
206
}
224
207
@@ -263,10 +246,9 @@ static void fixupReferenceCounts(
263
246
// Destroy the callee as the apply would have done if our function is not
264
247
// callee guaranteed.
265
248
if (!isCalleeGuaranteed) {
266
- insertAfterApply (
267
- applySite.getInstruction (), [&](SILBasicBlock::iterator iter) {
268
- SILBuilderWithScope (iter).emitDestroyValueOperation (loc, calleeValue);
269
- });
249
+ applySite.insertAfter ([&](SILBasicBlock::iterator iter) {
250
+ SILBuilderWithScope (iter).emitDestroyValueOperation (loc, calleeValue);
251
+ });
270
252
}
271
253
}
272
254
0 commit comments