Skip to content

Commit fc51ba1

Browse files
Merge pull request #35482 from aschwaighofer/fix_async_unreachable_lowering
IRGen: Fix unreachable lowering in async functions
2 parents 58625d2 + 17109cc commit fc51ba1

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,6 +3162,10 @@ void IRGenSILFunction::visitStringLiteralInst(swift::StringLiteralInst *i) {
31623162
}
31633163

31643164
void IRGenSILFunction::visitUnreachableInst(swift::UnreachableInst *i) {
3165+
if (isAsync()) {
3166+
emitCoroutineOrAsyncExit();
3167+
return;
3168+
}
31653169
Builder.CreateUnreachable();
31663170
}
31673171

test/Concurrency/Runtime/mainactor.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
// REQUIRES: executable_test
44
// REQUIRES: concurrency
5-
// REQUIRES: rdar73262638
65

76
// REQUIRES: OS=macosx || OS=ios
87
// FIXME: should not require Darwin to run this test once we have async main!

test/IRGen/async/unreachable.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %target-swift-frontend -primary-file %s -emit-ir -enable-experimental-concurrency -disable-llvm-optzns -disable-swift-specific-llvm-optzns | %FileCheck %s
2+
// REQUIRES: concurrency
3+
4+
// CHECK: call i1 @llvm.coro.end
5+
func foo() async -> Never {
6+
await bar()
7+
fatalError()
8+
}
9+
10+
// CHECK: call i1 @llvm.coro.end
11+
func bar() async -> Never {
12+
await foo()
13+
fatalError()
14+
}

0 commit comments

Comments
 (0)