Skip to content

Commit bfd865b

Browse files
committed
[ApplySite] Renamed insertAfterApplication.
Now that it can be called on partial_apply instructions, insertAfterFullEvaluation does not name what the function does. One could imagine a function which inserted after the applies of (non-escaping) partial_applies.
1 parent 8067882 commit bfd865b

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

include/swift/SIL/ApplySite.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,17 +485,21 @@ class ApplySite {
485485
///
486486
/// NOTE: We pass std::next() for begin_apply. If one wishes to insert code
487487
/// /after/ the end_apply/abort_apply, please use instead
488-
/// insertAfterFullEvaluation.
488+
/// insertAfterApplication.
489489
void insertAfterInvocation(function_ref<void(SILBuilder &)> func) const;
490490

491491
/// Pass a builder with insertion points that are guaranteed to be immediately
492-
/// after this full apply site has completely finished executing.
492+
/// after this apply site has been applied.
493+
///
494+
/// For apply and try_apply, that means after the apply. For partial_apply,
495+
/// that means after the partial_apply. For begin_apply, that means after its
496+
/// end_apply and abort_apply instructions.
493497
///
494498
/// This is just like insertAfterInvocation except that if the full apply site
495499
/// is a begin_apply, we pass the insertion points after the end_apply,
496500
/// abort_apply rather than an insertion point right after the
497501
/// begin_apply. For such functionality, please invoke insertAfterInvocation.
498-
void insertAfterFullEvaluation(function_ref<void(SILBuilder &)> func) const;
502+
void insertAfterApplication(function_ref<void(SILBuilder &)> func) const;
499503

500504
/// Return whether the given apply is of a formally-throwing function
501505
/// which is statically known not to throw.

lib/SIL/IR/ApplySite.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void ApplySite::insertAfterInvocation(function_ref<void(SILBuilder &)> func) con
2020
SILBuilderWithScope::insertAfter(getInstruction(), func);
2121
}
2222

23-
void ApplySite::insertAfterFullEvaluation(
23+
void ApplySite::insertAfterApplication(
2424
function_ref<void(SILBuilder &)> func) const {
2525
switch (getKind()) {
2626
case ApplySiteKind::ApplyInst:

lib/SILOptimizer/Mandatory/AddressLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ void CallArgRewriter::rewriteIndirectArgument(Operand *operand) {
17771777
if (apply.getArgumentConvention(*operand).isOwnedConvention()) {
17781778
argBuilder.createTrivialStoreOr(apply.getLoc(), argValue, allocInst,
17791779
StoreOwnershipQualifier::Init);
1780-
apply.insertAfterFullEvaluation([&](SILBuilder &callBuilder) {
1780+
apply.insertAfterApplication([&](SILBuilder &callBuilder) {
17811781
callBuilder.createDeallocStack(callLoc, allocInst);
17821782
});
17831783
operand->set(allocInst);
@@ -1786,7 +1786,7 @@ void CallArgRewriter::rewriteIndirectArgument(Operand *operand) {
17861786
auto *store =
17871787
argBuilder.emitStoreBorrowOperation(callLoc, borrow, allocInst);
17881788
auto *storeBorrow = dyn_cast<StoreBorrowInst>(store);
1789-
apply.insertAfterFullEvaluation([&](SILBuilder &callBuilder) {
1789+
apply.insertAfterApplication([&](SILBuilder &callBuilder) {
17901790
if (storeBorrow) {
17911791
callBuilder.emitEndBorrowOperation(callLoc, storeBorrow);
17921792
}
@@ -2071,7 +2071,7 @@ SILValue ApplyRewriter::materializeIndirectResultAddress(SILValue oldResult,
20712071

20722072
// Instead of using resultBuilder, insert dealloc immediately after the call
20732073
// for stack discipline across loadable indirect results.
2074-
apply.insertAfterFullEvaluation([&](SILBuilder &callBuilder) {
2074+
apply.insertAfterApplication([&](SILBuilder &callBuilder) {
20752075
callBuilder.createDeallocStack(callLoc, allocInst);
20762076
});
20772077

lib/SILOptimizer/Mandatory/ClosureLifetimeFixup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ static void insertAfterClosureUser(SILInstruction *closureUser,
431431
}
432432
FullApplySite fas = FullApplySite::isa(closureUser);
433433
assert(fas);
434-
fas.insertAfterFullEvaluation(insertAtNonUnreachable);
434+
fas.insertAfterApplication(insertAtNonUnreachable);
435435
}
436436

437437
static SILValue skipConvert(SILValue v) {

lib/SILOptimizer/Utils/Generics.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,7 +2337,7 @@ replaceWithSpecializedCallee(ApplySite applySite, SILValue callee,
23372337
SILBasicBlock *resultBlock = tai->getNormalBB();
23382338
assert(resultBlock->getSinglePredecessorBlock() == tai->getParent());
23392339
// First insert the cleanups for our arguments int he appropriate spot.
2340-
FullApplySite(tai).insertAfterFullEvaluation(
2340+
FullApplySite(tai).insertAfterApplication(
23412341
[&](SILBuilder &argBuilder) {
23422342
cleanupCallArguments(argBuilder, loc, arguments,
23432343
argsNeedingEndBorrow);
@@ -2363,7 +2363,7 @@ replaceWithSpecializedCallee(ApplySite applySite, SILValue callee,
23632363
}
23642364
case ApplySiteKind::ApplyInst: {
23652365
auto *ai = cast<ApplyInst>(applySite);
2366-
FullApplySite(ai).insertAfterFullEvaluation(
2366+
FullApplySite(ai).insertAfterApplication(
23672367
[&](SILBuilder &argBuilder) {
23682368
cleanupCallArguments(argBuilder, loc, arguments,
23692369
argsNeedingEndBorrow);
@@ -2400,7 +2400,7 @@ replaceWithSpecializedCallee(ApplySite applySite, SILValue callee,
24002400
case ApplySiteKind::BeginApplyInst: {
24012401
auto *bai = cast<BeginApplyInst>(applySite);
24022402
assert(!resultOut);
2403-
FullApplySite(bai).insertAfterFullEvaluation(
2403+
FullApplySite(bai).insertAfterApplication(
24042404
[&](SILBuilder &argBuilder) {
24052405
cleanupCallArguments(argBuilder, loc, arguments,
24062406
argsNeedingEndBorrow);
@@ -2582,7 +2582,7 @@ SILFunction *ReabstractionThunkGenerator::createThunk() {
25822582

25832583
// Now that we have finished constructing our CFG (note the return above),
25842584
// insert any compensating end borrows that we need.
2585-
ApplySite.insertAfterFullEvaluation([&](SILBuilder &argBuilder) {
2585+
ApplySite.insertAfterApplication([&](SILBuilder &argBuilder) {
25862586
cleanupCallArguments(argBuilder, Loc, Arguments, ArgsThatNeedEndBorrow);
25872587
});
25882588

lib/SILOptimizer/Utils/PartialApplyCombiner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void PartialApplyCombiner::processSingleApply(FullApplySite paiAI) {
179179
auto *ASI = builder.createAllocStack(pai->getLoc(), arg->getType());
180180
builder.createCopyAddr(pai->getLoc(), arg, ASI, IsTake_t::IsNotTake,
181181
IsInitialization_t::IsInitialization);
182-
paiAI.insertAfterFullEvaluation([&](SILBuilder &builder) {
182+
paiAI.insertAfterApplication([&](SILBuilder &builder) {
183183
builder.createDeallocStack(destroyloc, ASI);
184184
});
185185
arg = ASI;
@@ -207,7 +207,7 @@ void PartialApplyCombiner::processSingleApply(FullApplySite paiAI) {
207207
// We also need to destroy the partial_apply instruction itself because it is
208208
// consumed by the apply_instruction.
209209
if (!pai->hasCalleeGuaranteedContext()) {
210-
paiAI.insertAfterFullEvaluation([&](SILBuilder &builder) {
210+
paiAI.insertAfterApplication([&](SILBuilder &builder) {
211211
builder.emitDestroyValueOperation(destroyloc, pai);
212212
});
213213
}

0 commit comments

Comments
 (0)