Skip to content

Commit d1b185a

Browse files
Merge pull request #42454 from aschwaighofer/irgen_suspend_point_debug_info
IRGen: Use the current function name for the swift_suspend_point thunk
2 parents 34db837 + ab10f79 commit d1b185a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
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/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)