[clang] Extend `retcon.once` coroutines lowering to optionally produce a normal result (PR #66333)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 14 02:11:17 PDT 2023


================
@@ -3046,7 +3046,8 @@ void coro::buildCoroutineFrame(
   // Collect the spills for arguments and other not-materializable values.
   for (Argument &A : F.args())
     for (User *U : A.users())
-      if (Checker.isDefinitionAcrossSuspend(A, U))
+      if (Checker.isDefinitionAcrossSuspend(A, U) ||
+          isa<CoroEndInst>(U))
----------------
ChuanqiXu9 wrote:

Got it. Then it smells slightly bad. We have a lot `isDefinitionAcrossSuspend` uses and it looks easy to forget similar cases. I feel better to solve the issue fundamentally by introducing new intrinsics.

e.g., we can introduce  `token  llvm.coro.end.retcont.return_values(...)` and refactor `llvm.coro.end()` to `declare i1 @llvm.coro.end(ptr <handle>, i1 <unwind>, token <return>)`. And for non-retcon-once ABI, we can fill the third argument as `none` simply. For retcon-once ABI, it should be easy to generate the actual ret too. 

Then we can avoid the `isDefinitionAcrossSuspend` problem automatically since the BB will be split around `coro.end`.

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


More information about the cfe-commits mailing list