Skip to content

Commit 7438d49

Browse files
committed
Move code to proper switch
While upstreaming patches this code somehow was applied to the wrong switch statement. Differential Revision: https://reviews.llvm.org/D105504
1 parent 6e250ca commit 7438d49

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

llvm/lib/Transforms/Coroutines/CoroSplit.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -913,10 +913,21 @@ void CoroCloner::create() {
913913
Shape.FrameSize, Shape.FrameAlign);
914914
break;
915915
case coro::ABI::Async: {
916+
auto *ActiveAsyncSuspend = cast<CoroSuspendAsyncInst>(ActiveSuspend);
916917
if (OrigF.hasParamAttribute(Shape.AsyncLowering.ContextArgNo,
917918
Attribute::SwiftAsync)) {
918-
addAsyncContextAttrs(NewAttrs, Context, Shape.AsyncLowering.ContextArgNo);
919+
uint32_t ArgAttributeIndices =
920+
ActiveAsyncSuspend->getStorageArgumentIndex();
921+
auto ContextArgIndex = ArgAttributeIndices & 0xff;
922+
addAsyncContextAttrs(NewAttrs, Context, ContextArgIndex);
923+
924+
// `swiftasync` must preceed `swiftself` so 0 is not a valid index for
925+
// `swiftself`.
926+
auto SwiftSelfIndex = ArgAttributeIndices >> 8;
927+
if (SwiftSelfIndex)
928+
addSwiftSelfAttrs(NewAttrs, Context, SwiftSelfIndex);
919929
}
930+
920931
// Transfer the original function's attributes.
921932
auto FnAttrs = OrigF.getAttributes().getFnAttributes();
922933
NewAttrs =
@@ -956,24 +967,9 @@ void CoroCloner::create() {
956967
// followed by a return.
957968
// Don't change returns to unreachable because that will trip up the verifier.
958969
// These returns should be unreachable from the clone.
959-
case coro::ABI::Async: {
960-
auto *ActiveAsyncSuspend = cast<CoroSuspendAsyncInst>(ActiveSuspend);
961-
if (OrigF.hasParamAttribute(Shape.AsyncLowering.ContextArgNo,
962-
Attribute::SwiftAsync)) {
963-
uint32_t ArgAttributeIndices =
964-
ActiveAsyncSuspend->getStorageArgumentIndex();
965-
auto ContextArgIndex = ArgAttributeIndices & 0xff;
966-
addAsyncContextAttrs(NewAttrs, Context, ContextArgIndex);
967-
968-
// `swiftasync` must preceed `swiftself` so 0 is not a valid index for
969-
// `swiftself`.
970-
auto SwiftSelfIndex = ArgAttributeIndices >> 8;
971-
if (SwiftSelfIndex)
972-
addSwiftSelfAttrs(NewAttrs, Context, SwiftSelfIndex);
973-
}
970+
case coro::ABI::Async:
974971
break;
975972
}
976-
}
977973

978974
NewF->setAttributes(NewAttrs);
979975
NewF->setCallingConv(Shape.getResumeFunctionCC());

0 commit comments

Comments
 (0)