Skip to content

Commit fc93c17

Browse files
Merge pull request #42481 from aschwaighofer/irgen_suspend_point_debug_info_5.7
[5.7] IRGen: Use the current function name for the swift_suspend_point thunk
2 parents 52a246d + 13624e0 commit fc93c17

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

lib/IRGen/GenFunc.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,7 +2434,9 @@ llvm::Function *IRGenFunction::getOrCreateResumeFromSuspensionFn() {
24342434
}
24352435

24362436
llvm::Function *IRGenFunction::createAsyncSuspendFn() {
2437-
StringRef name = "__swift_suspend_point";
2437+
llvm::SmallString<40> nameBuffer;
2438+
llvm::raw_svector_ostream(nameBuffer) << CurFn->getName() << ".1";
2439+
StringRef name(nameBuffer);
24382440
if (llvm::GlobalValue *F = IGM.Module.getNamedValue(name))
24392441
return cast<llvm::Function>(F);
24402442

@@ -2455,7 +2457,8 @@ llvm::Function *IRGenFunction::createAsyncSuspendFn() {
24552457
suspendFn->setDoesNotThrow();
24562458
IRGenFunction suspendIGF(IGM, suspendFn);
24572459
if (IGM.DebugInfo)
2458-
IGM.DebugInfo->emitArtificialFunction(suspendIGF, suspendFn);
2460+
IGM.DebugInfo->emitOutlinedFunction(suspendIGF, suspendFn,
2461+
CurFn->getName());
24592462
auto &Builder = suspendIGF.Builder;
24602463

24612464
llvm::Value *resumeFunction = suspendFn->getArg(0);

test/DebugInfo/move_function_dbginfo_async.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public func letSimpleTest<T>(_ msg: __owned T) async {
8989
// CHECK-LABEL: define internal swifttailcc void @"$s27move_function_dbginfo_async13varSimpleTestyyxz_xtYalFTQ0_"(i8* swiftasync %0)
9090
// CHECK: entryresume.0:
9191
// CHECK: call void @llvm.dbg.addr(metadata i8* %0, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8, DW_OP_deref))
92-
// CHECK: musttail call swifttailcc void @swift_task_switch(%swift.context* swiftasync %9, i8* bitcast (void (i8*)* @"$s27move_function_dbginfo_async13varSimpleTestyyxz_xtYalFTY1_" to i8*), i64 0, i64 0)
92+
// CHECK: musttail call swifttailcc void @swift_task_switch(%swift.context* swiftasync %{{[0-9]+}}, i8* bitcast (void (i8*)* @"$s27move_function_dbginfo_async13varSimpleTestyyxz_xtYalFTY1_" to i8*), i64 0, i64 0)
9393
// CHECK-NEXT: ret void
9494
// CHECK-NEXT: }
9595
//

test/IRGen/async/hop_to_executor.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import _Concurrency
1616
// CHECK-SAME: %swift.context* swiftasync %0, [[INT]] %1, [[INT]] %2)
1717
// CHECK-DAG: [[CTX:%[0-9]+]] = bitcast %swift.context* %0
1818
// CHECK-DAG: [[RESUME:%[0-9]+]] = call i8* @llvm.coro.async.resume()
19-
// CHECK-x86_64: call {{.*}} @llvm.coro.suspend.async{{.*}}(i32 0, i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, [[INT]], [[INT]], %swift.context*)* @__swift_suspend_point to i8*), i8* [[RESUME]], [[INT]] %1, [[INT]] %2, %swift.context* {{%[0-9]+}})
20-
// CHECK-arm64e: call {{.*}} @llvm.coro.suspend.async{{.*}}(i32 0, i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, [[INT]], [[INT]], %swift.context*)* @__swift_suspend_point to i8*), i8* [[RESUME]], [[INT]] %1, [[INT]] %2, %swift.context* {{%[0-9]+}})
19+
// CHECK-x86_64: call {{.*}} @llvm.coro.suspend.async{{.*}}(i32 0, i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, [[INT]], [[INT]], %swift.context*)* @test_simple.1 to i8*), i8* [[RESUME]], [[INT]] %1, [[INT]] %2, %swift.context* {{%[0-9]+}})
20+
// CHECK-arm64e: call {{.*}} @llvm.coro.suspend.async{{.*}}(i32 0, i8* [[RESUME]], i8* bitcast (i8* (i8*)* @__swift_async_resume_get_context to i8*), i8* bitcast (void (i8*, [[INT]], [[INT]], %swift.context*)* @test_simple.1 to i8*), i8* [[RESUME]], [[INT]] %1, [[INT]] %2, %swift.context* {{%[0-9]+}})
2121
// CHECK: [[RET_CONTINUATION:%.*]] = bitcast void (%swift.context*)* {{.*}} to i8*
2222
// CHECK: call i1 (i8*, i1, ...) @llvm.coro.end.async(i8* {{.*}}, i1 false, void (i8*, %swift.context*)* @[[TAIL_CALL_FUNC:.*]], i8* [[RET_CONTINUATION]]
2323
// CHECK-WIN: ret void
@@ -30,7 +30,7 @@ bb0(%0 : $Optional<Builtin.Executor>):
3030
return %3 : $()
3131
}
3232

33-
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @__swift_suspend_point
33+
// CHECK-LABEL: define internal swift{{(tail)?}}cc void @test_simple.1
3434
// CHECK-SAME: (i8* [[RESUME_FN:%0]], [[INT]] %1, [[INT]] %2, %swift.context* [[CTXT:%[^,]+]])
3535
// CHECK-arm64e: [[RESUME_FN_INT:%[^,]+]] = ptrtoint i8* [[RESUME_FN]] to i64
3636
// CHECK-arm64e: [[PTRAUTH_SIGN:%[^,]+]] = call i64 @llvm.ptrauth.sign.i64(i64 [[RESUME_FN_INT]], i32 0, i64 0)

0 commit comments

Comments
 (0)