[clang] [llvm] Implement llvm.coro.await.suspend intrinsic (PR #79712)

via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 27 14:50:15 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 53fea6fd6f228eb1dbd282b8d076af545dcd8228 858e207bc33466ed85ecf6a7e8718c2e6153f4fe -- clang/test/CodeGenCoroutines/coro-simplify-suspend-point.cpp clang/include/clang/AST/ExprCXX.h clang/lib/CodeGen/CGCoroutine.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/Sema/SemaCoroutine.cpp clang/test/AST/coroutine-locals-cleanup.cpp clang/test/CodeGenCoroutines/coro-always-inline.cpp clang/test/CodeGenCoroutines/coro-await.cpp clang/test/CodeGenCoroutines/coro-dwarf.cpp clang/test/CodeGenCoroutines/coro-function-try-block.cpp clang/test/CodeGenCoroutines/coro-symmetric-transfer-01.cpp clang/test/CodeGenCoroutines/coro-symmetric-transfer-02.cpp clang/test/CodeGenCoroutines/pr59181.cpp clang/test/SemaCXX/co_await-ast.cpp llvm/lib/IR/Verifier.cpp llvm/lib/Transforms/Coroutines/CoroInstr.h llvm/lib/Transforms/Coroutines/CoroSplit.cpp llvm/lib/Transforms/Coroutines/Coroutines.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index e01db71a46..4e9b8a394f 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -2123,27 +2123,27 @@ static coro::Shape
 splitCoroutine(Module &M, Function &F, SmallVectorImpl<Function *> &Clones,
                TargetTransformInfo &TTI, bool OptimizeFrame,
                std::function<bool(Instruction &)> MaterializableCallback) {
-    PrettyStackTraceFunction prettyStackTrace(F);
+  PrettyStackTraceFunction prettyStackTrace(F);
 
-    // The suspend-crossing algorithm in buildCoroutineFrame get tripped
-    // up by uses in unreachable blocks, so remove them as a first pass.
-    removeUnreachableBlocks(F);
+  // The suspend-crossing algorithm in buildCoroutineFrame get tripped
+  // up by uses in unreachable blocks, so remove them as a first pass.
+  removeUnreachableBlocks(F);
 
-    coro::Shape Shape(F, OptimizeFrame);
-    if (!Shape.CoroBegin)
-      return Shape;
+  coro::Shape Shape(F, OptimizeFrame);
+  if (!Shape.CoroBegin)
+    return Shape;
 
-    simplifySuspendPoints(Shape);
-    buildCoroutineFrame(F, Shape, MaterializableCallback);
-    replaceFrameSizeAndAlignment(Shape);
+  simplifySuspendPoints(Shape);
+  buildCoroutineFrame(F, Shape, MaterializableCallback);
+  replaceFrameSizeAndAlignment(Shape);
 
-    // If there are no suspend points, no split required, just remove
-    // the allocation and deallocation blocks, they are not needed.
-    if (Shape.CoroSuspends.empty()) {
-      handleNoSuspendCoroutine(Shape);
-    } else {
-      switch (Shape.ABI) {
-      case coro::ABI::Switch:
+  // If there are no suspend points, no split required, just remove
+  // the allocation and deallocation blocks, they are not needed.
+  if (Shape.CoroSuspends.empty()) {
+    handleNoSuspendCoroutine(Shape);
+  } else {
+    switch (Shape.ABI) {
+    case coro::ABI::Switch:
       splitSwitchCoroutine(M, F, Shape, Clones, TTI);
       break;
     case coro::ABI::Async:
@@ -2154,7 +2154,7 @@ splitCoroutine(Module &M, Function &F, SmallVectorImpl<Function *> &Clones,
       splitRetconCoroutine(F, Shape, Clones);
       break;
     }
-    }
+  }
 
   // Replace all the swifterror operations in the original function.
   // This invalidates SwiftErrorOps in the Shape.

``````````

</details>


https://github.com/llvm/llvm-project/pull/79712


More information about the cfe-commits mailing list