Skip to content

Commit 18f8507

Browse files
committed
ApplySite::getPseudoResult
This returns the fake tuple value for either an apply or try_apply. This is not actually a result. It is composed of the results.
1 parent 83b01d8 commit 18f8507

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

include/swift/SIL/ApplySite.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -580,18 +580,19 @@ class FullApplySite : public ApplySite {
580580
return getSubstCalleeConv().hasIndirectSILResults();
581581
}
582582

583-
/// If our apply site has a single direct result SILValue, return that
584-
/// SILValue. Return SILValue() otherwise.
583+
/// Get the SIL value that represents all of the given call's results. For a
584+
/// single direct result, returns the result. For multiple results, returns a
585+
/// fake tuple value. The tuple has no storage of its own. The real results
586+
/// must be extracted from it.
585587
///
586-
/// This means that:
588+
/// For ApplyInst, returns the single-value instruction itself.
587589
///
588-
/// 1. If we have an ApplyInst, we just visit the apply.
589-
/// 2. If we have a TryApplyInst, we visit the first argument of the normal
590-
/// block.
591-
/// 3. If we have a BeginApplyInst, we return SILValue() since the begin_apply
592-
/// yields values instead of returning them. A returned value should only
593-
/// be valid after a full apply site has completely finished executing.
594-
SILValue getSingleDirectResult() const {
590+
/// For TryApplyInst returns the continuation block argument.
591+
///
592+
/// For BeginApplyInst, returns an invalid value. For coroutines, there is no
593+
/// single value representing all results. Yielded values are generally
594+
/// handled differently since they have the convention of incoming arguments.
595+
SILValue getPseudoResult() const {
595596
switch (getKind()) {
596597
case FullApplySiteKind::ApplyInst:
597598
return SILValue(cast<ApplyInst>(getInstruction()));

lib/SILOptimizer/Utils/Generics.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,8 +2244,8 @@ SILFunction *ReabstractionThunkGenerator::createThunk() {
22442244
Arguments.push_back(NewArg);
22452245
}
22462246
FullApplySite ApplySite = createReabstractionThunkApply(Builder);
2247-
SILValue ReturnValue = ApplySite.getSingleDirectResult();
2248-
assert(ReturnValue && "getSingleDirectResult out of sync with ApplySite?!");
2247+
SILValue ReturnValue = ApplySite.getPseudoResult();
2248+
assert(ReturnValue && "getPseudoResult out of sync with ApplySite?!");
22492249
Builder.createReturn(Loc, ReturnValue);
22502250

22512251
return Thunk;
@@ -2257,8 +2257,8 @@ SILFunction *ReabstractionThunkGenerator::createThunk() {
22572257

22582258
FullApplySite ApplySite = createReabstractionThunkApply(Builder);
22592259

2260-
SILValue ReturnValue = ApplySite.getSingleDirectResult();
2261-
assert(ReturnValue && "getSingleDirectResult out of sync with ApplySite?!");
2260+
SILValue ReturnValue = ApplySite.getPseudoResult();
2261+
assert(ReturnValue && "getPseudoResult out of sync with ApplySite?!");
22622262

22632263
if (ReturnValueAddr) {
22642264
// Need to store the direct results to the original indirect address.

0 commit comments

Comments
 (0)