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

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 17 19:53:15 PST 2024


================
@@ -1396,9 +1478,18 @@ static bool simplifySuspendPoint(CoroSuspendInst *Suspend,
   if (!SubFn)
     return false;
 
-  // Does not refer to the current coroutine, we cannot do anything with it.
-  if (SubFn->getFrame() != CoroBegin)
-    return false;
+  auto Frame = SubFn->getFrame();
+
+  // Check that frame directly always refers to the current coroutine,
+  // either directly or via wrapper
+  if (Frame != CoroBegin) {
+    auto *AWS = dyn_cast<CoroAwaitSuspendInst>(Frame);
+    if (!AWS)
+      return false;
----------------
ChuanqiXu9 wrote:

Since we've lowered all `CoroAwaitSuspendInst` before invoking `splitCoroutine`. We shouldn't see `CoroAwaitSuspendInst` here, right?

Then we can remove  isSimpleWrapper too.

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


More information about the cfe-commits mailing list