[llvm] 033de11 - [coro async] Move code to proper switch
Arnold Schwaighofer via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 7 06:19:36 PDT 2021
Author: Arnold Schwaighofer
Date: 2021-07-07T06:19:08-07:00
New Revision: 033de11150d3f34679ff5447600b99bb0c511ea6
URL: https://github.com/llvm/llvm-project/commit/033de11150d3f34679ff5447600b99bb0c511ea6
DIFF: https://github.com/llvm/llvm-project/commit/033de11150d3f34679ff5447600b99bb0c511ea6.diff
LOG: [coro async] 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
Added:
Modified:
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index 402066cd36fe..c73bc5df63f1 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -913,6 +913,21 @@ void CoroCloner::create() {
Shape.FrameSize, Shape.FrameAlign);
break;
case coro::ABI::Async: {
+ auto *ActiveAsyncSuspend = cast<CoroSuspendAsyncInst>(ActiveSuspend);
+ if (OrigF.hasParamAttribute(Shape.AsyncLowering.ContextArgNo,
+ Attribute::SwiftAsync)) {
+ uint32_t ArgAttributeIndices =
+ ActiveAsyncSuspend->getStorageArgumentIndex();
+ auto ContextArgIndex = ArgAttributeIndices & 0xff;
+ addAsyncContextAttrs(NewAttrs, Context, ContextArgIndex);
+
+ // `swiftasync` must preceed `swiftself` so 0 is not a valid index for
+ // `swiftself`.
+ auto SwiftSelfIndex = ArgAttributeIndices >> 8;
+ if (SwiftSelfIndex)
+ addSwiftSelfAttrs(NewAttrs, Context, SwiftSelfIndex);
+ }
+
// Transfer the original function's attributes.
auto FnAttrs = OrigF.getAttributes().getFnAttributes();
NewAttrs =
@@ -952,24 +967,9 @@ void CoroCloner::create() {
// followed by a return.
// Don't change returns to unreachable because that will trip up the verifier.
// These returns should be unreachable from the clone.
- case coro::ABI::Async: {
- auto *ActiveAsyncSuspend = cast<CoroSuspendAsyncInst>(ActiveSuspend);
- if (OrigF.hasParamAttribute(Shape.AsyncLowering.ContextArgNo,
- Attribute::SwiftAsync)) {
- uint32_t ArgAttributeIndices =
- ActiveAsyncSuspend->getStorageArgumentIndex();
- auto ContextArgIndex = ArgAttributeIndices & 0xff;
- addAsyncContextAttrs(NewAttrs, Context, ContextArgIndex);
-
- // `swiftasync` must preceed `swiftself` so 0 is not a valid index for
- // `swiftself`.
- auto SwiftSelfIndex = ArgAttributeIndices >> 8;
- if (SwiftSelfIndex)
- addSwiftSelfAttrs(NewAttrs, Context, SwiftSelfIndex);
- }
+ case coro::ABI::Async:
break;
}
- }
NewF->setAttributes(NewAttrs);
NewF->setCallingConv(Shape.getResumeFunctionCC());
More information about the llvm-commits
mailing list