Skip to content

Commit 6696bcf

Browse files
committed
IRGen: Fix the insert point after inserting the dynamic replacement prolog
The code used the last basic block in the function instead of the last basic block created for the dynamic replacement prolog. rdar://77073666
1 parent c472ce4 commit 6696bcf

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,7 @@ static void emitEntryPointArgumentsNativeCC(IRGenSILFunction &IGF,
19581958
if (IGF.CurSILFn->isDynamicallyReplaceable()) {
19591959
IGF.IGM.createReplaceableProlog(IGF, IGF.CurSILFn);
19601960
// Remap the entry block.
1961-
IGF.LoweredBBs[&*IGF.CurSILFn->begin()] = LoweredBB(&IGF.CurFn->back(), {});
1961+
IGF.LoweredBBs[&*IGF.CurSILFn->begin()] = LoweredBB(IGF.Builder.GetInsertBlock(), {});
19621962
}
19631963
}
19641964

test/Interpreter/async_dynamic.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,29 @@ public dynamic func number() async -> Int {
1212
return 100
1313
}
1414

15+
enum SomeError : Error {
16+
case err
17+
}
18+
19+
class C {
20+
dynamic func a() async throws -> Int? {
21+
return 0
22+
}
23+
24+
dynamic func b() async throws {
25+
guard let data = try await a() else {
26+
throw SomeError.err
27+
}
28+
}
29+
30+
}
1531
@main struct Main {
32+
1633
static func main() async {
34+
do {
35+
try await C().b()
36+
} catch _ { assertionFailure("should not throw") }
37+
1738
// CHECK: 100
1839
let value = await number()
1940
print(value)

0 commit comments

Comments
 (0)