Skip to content

Commit 590ac0a

Browse files
committed
[coro async] Transfer the original function's attributes to the clone
rdar://75052917 Differential Revision: https://reviews.llvm.org/D98051
1 parent ea659ea commit 590ac0a

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

llvm/lib/Transforms/Coroutines/CoroSplit.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,13 @@ void CoroCloner::create() {
878878
addFramePointerAttrs(NewAttrs, Context, 0,
879879
Shape.FrameSize, Shape.FrameAlign);
880880
break;
881-
case coro::ABI::Async:
881+
case coro::ABI::Async: {
882+
// Transfer the original function's attributes.
883+
auto FnAttrs = OrigF.getAttributes().getFnAttributes();
884+
NewAttrs =
885+
NewAttrs.addAttributes(Context, AttributeList::FunctionIndex, FnAttrs);
882886
break;
887+
}
883888
case coro::ABI::Retcon:
884889
case coro::ABI::RetconOnce:
885890
// If we have a continuation prototype, just use its attributes,
@@ -1272,6 +1277,7 @@ static void handleNoSuspendCoroutine(coro::Shape &Shape) {
12721277
} else {
12731278
CoroBegin->replaceAllUsesWith(CoroBegin->getMem());
12741279
}
1280+
12751281
break;
12761282
}
12771283
case coro::ABI::Async:

llvm/test/Transforms/Coroutines/coro-async.ll

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ define void @my_async_function_pa(i8* %ctxt, %async.task* %task, %async.actor* %
187187
i32 128 ; Initial async context size without space for frame
188188
}>
189189

190-
define swiftcc void @my_async_function2(%async.task* %task, %async.actor* %actor, i8* %async.ctxt) {
190+
define swiftcc void @my_async_function2(%async.task* %task, %async.actor* %actor, i8* %async.ctxt) "frame-pointer"="all" {
191191
entry:
192192

193193
%id = call token @llvm.coro.id.async(i32 128, i32 16, i32 2, i8* bitcast (<{i32, i32}>* @my_async_function2_fp to i8*))
@@ -239,7 +239,8 @@ entry:
239239
unreachable
240240
}
241241

242-
; CHECK-LABEL: define swiftcc void @my_async_function2(%async.task* %task, %async.actor* %actor, i8* %async.ctxt) {
242+
; CHECK-LABEL: define swiftcc void @my_async_function2(%async.task* %task, %async.actor* %actor, i8* %async.ctxt)
243+
; CHECK-SAME: #[[FRAMEPOINTER:[0-9]+]]
243244
; CHECK: store i8* %async.ctxt,
244245
; CHECK: store %async.actor* %actor,
245246
; CHECK: store %async.task* %task,
@@ -250,7 +251,8 @@ entry:
250251
; CHECK: tail call swiftcc void @asyncSuspend(i8* [[CALLEE_CTXT]], %async.task* %task, %async.actor* %actor)
251252
; CHECK: ret void
252253

253-
; CHECK-LABEL: define internal swiftcc void @my_async_function2.resume.0(i8* %0, i8* nocapture readnone %1, i8* nocapture readonly %2) {
254+
; CHECK-LABEL: define internal swiftcc void @my_async_function2.resume.0(i8* %0, i8* nocapture readnone %1, i8* nocapture readonly %2)
255+
; CHECK-SAME: #[[FRAMEPOINTER]]
254256
; CHECK: [[CALLEE_CTXT_ADDR:%.*]] = bitcast i8* %2 to i8**
255257
; CHECK: [[CALLEE_CTXT:%.*]] = load i8*, i8** [[CALLEE_CTXT_ADDR]]
256258
; CHECK: [[CALLEE_CTXT_SPILL_ADDR:%.*]] = getelementptr inbounds i8, i8* [[CALLEE_CTXT]], i64 152
@@ -260,7 +262,8 @@ entry:
260262
; CHECK: tail call swiftcc void @asyncSuspend(i8* [[CALLEE_CTXT_RELOAD]]
261263
; CHECK: ret void
262264

263-
; CHECK-LABEL: define internal swiftcc void @my_async_function2.resume.1(i8* nocapture readonly %0, i8* %1, i8* nocapture readnone %2) {
265+
; CHECK-LABEL: define internal swiftcc void @my_async_function2.resume.1(i8* nocapture readonly %0, i8* %1, i8* nocapture readnone %2)
266+
; CHECK-SAME: #[[FRAMEPOINTER]]
264267
; CHECK: bitcast i8* %0 to i8**
265268
; CHECK: [[ACTOR_ARG:%.*]] = bitcast i8* %1
266269
; CHECK: tail call swiftcc void @asyncReturn({{.*}}[[ACTOR_ARG]])

0 commit comments

Comments
 (0)