Skip to content

Commit 45bb167

Browse files
committed
[region-isolation] Add support for await_async_continuation.
1 parent 4218f5b commit 45bb167

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,13 @@ enum class TranslationSemantics {
11571157
/// handle every instruction to ensure we cover the IR.
11581158
Asserting,
11591159

1160+
/// An instruction that the checker thinks it can ignore as long as all of its
1161+
/// operands are Sendable. If we see that such an instruction has a
1162+
/// non-Sendable parameter, then someone added an instruction to the compiler
1163+
/// without updating this code correctly. This is most likely driver error and
1164+
/// should be caught in testing when we assert.
1165+
AssertingIfNonSendable,
1166+
11601167
/// An instruction that we do not handle yet. Just for now during bring
11611168
/// up. Will be removed.
11621169
Unhandled,
@@ -1199,6 +1206,9 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
11991206
case TranslationSemantics::Asserting:
12001207
os << "asserting";
12011208
return os;
1209+
case TranslationSemantics::AssertingIfNonSendable:
1210+
os << "asserting_if_nonsendable";
1211+
return os;
12021212
case TranslationSemantics::Unhandled:
12031213
os << "unhandled";
12041214
return os;
@@ -2104,6 +2114,16 @@ class PartitionOpTranslator {
21042114
case TranslationSemantics::Unhandled:
21052115
LLVM_DEBUG(llvm::dbgs() << "Unhandled inst: " << *inst);
21062116
return;
2117+
case TranslationSemantics::AssertingIfNonSendable:
2118+
// Do not error if all of our operands are sendable.
2119+
if (llvm::none_of(inst->getOperandValues(), [&](SILValue value) {
2120+
return ::isNonSendableType(value->getType(), inst->getFunction());
2121+
}))
2122+
return;
2123+
llvm::report_fatal_error(
2124+
"transfer-non-sendable: Found instruction that is not allowed to "
2125+
"have non-Sendable parameters with such parameters?!");
2126+
return;
21072127
}
21082128

21092129
llvm_unreachable("Covered switch isn't covered?!");
@@ -2400,6 +2420,10 @@ CONSTANT_TRANSLATION(CondBranchInst, TerminatorPhi)
24002420
CONSTANT_TRANSLATION(CheckedCastBranchInst, TerminatorPhi)
24012421
CONSTANT_TRANSLATION(DynamicMethodBranchInst, TerminatorPhi)
24022422

2423+
// Today, await_async_continuation just takes Sendable values
2424+
// (UnsafeContinuation and UnsafeThrowingContinuation).
2425+
CONSTANT_TRANSLATION(AwaitAsyncContinuationInst, AssertingIfNonSendable)
2426+
24032427
//===---
24042428
// Existential Box
24052429
//
@@ -2441,7 +2465,6 @@ CONSTANT_TRANSLATION(ExtractExecutorInst, Unhandled)
24412465
CONSTANT_TRANSLATION(BindMemoryInst, Unhandled)
24422466
CONSTANT_TRANSLATION(RebindMemoryInst, Unhandled)
24432467
CONSTANT_TRANSLATION(ThrowAddrInst, Unhandled)
2444-
CONSTANT_TRANSLATION(AwaitAsyncContinuationInst, Unhandled)
24452468
CONSTANT_TRANSLATION(BeginUnpairedAccessInst, Unhandled)
24462469
CONSTANT_TRANSLATION(EndUnpairedAccessInst, Unhandled)
24472470

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,3 +1376,4 @@ bb0:
13761376
%9999 = tuple ()
13771377
return %9999 : $()
13781378
}
1379+

0 commit comments

Comments
 (0)