Skip to content

Commit e9d29d0

Browse files
Merge pull request #2626 from aschwaighofer/fix_swiftasync_transfer_coro_split
fix transfer of swiftasync parameter
2 parents f8a3a94 + 9a06d0c commit e9d29d0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

llvm/lib/Transforms/Coroutines/CoroSplit.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ static Function *createCloneDeclaration(Function &OrigF, coro::Shape &Shape,
475475
Function *NewF =
476476
Function::Create(FnTy, GlobalValue::LinkageTypes::InternalLinkage,
477477
OrigF.getName() + Suffix);
478-
NewF->addParamAttr(0, Attribute::NonNull);
478+
if (Shape.ABI != coro::ABI::Async)
479+
NewF->addParamAttr(0, Attribute::NonNull);
479480

480481
// For the async lowering ABI we can't guarantee that the context argument is
481482
// not access via a different pointer not based on the argument.
@@ -883,8 +884,9 @@ void CoroCloner::create() {
883884
break;
884885
case coro::ABI::Async: {
885886
auto *ActiveAsyncSuspend = cast<CoroSuspendAsyncInst>(ActiveSuspend);
886-
auto ContextArgIndex = ActiveAsyncSuspend->getStorageArgumentIndex();
887-
if (OrigF.hasParamAttribute(ContextArgIndex, Attribute::SwiftAsync)) {
887+
if (OrigF.hasParamAttribute(Shape.AsyncLowering.ContextArgNo,
888+
Attribute::SwiftAsync)) {
889+
auto ContextArgIndex = ActiveAsyncSuspend->getStorageArgumentIndex();
888890
addAsyncContextAttrs(NewAttrs, Context, ContextArgIndex);
889891
}
890892

0 commit comments

Comments
 (0)