[clang] [llvm] [coro] Lower `llvm.coro.await.suspend.handle` to resume with tail call (PR #89751)

Chuanqi Xu via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 29 19:15:01 PDT 2024


================
@@ -1056,6 +1083,25 @@ void CoroCloner::create() {
   // Set up the new entry block.
   replaceEntryBlock();
 
+  // Turn symmetric transfers into musttail calls.
+  for (CallInst *ResumeCall : Shape.SymmetricTransfers) {
+    ResumeCall = cast<CallInst>(VMap[ResumeCall]);
+    ResumeCall->setCallingConv(NewF->getCallingConv());
+    if (TTI.supportsTailCallFor(ResumeCall)) {
+      // FIXME: Could we support symmetric transfer effectively without
+      // musttail?
+      ResumeCall->setTailCallKind(CallInst::TCK_MustTail);
+    }
+
+    // Put a 'ret void' after the call, and split any remaining instructions to
----------------
ChuanqiXu9 wrote:

> Also, maybe this would become moot if we address https://discourse.llvm.org/t/coro-pre-split-handling-of-the-suspend-edge/75043 like @jyknight suggested (i.e. not even have the misleading edge)?

But IIRC, it is still possible that we'll have code inserted between `llvm.coro.await.suspend.{.*}` and `llvm.coro.suspend`, which is the problem we're discussing.

> Sorry for insisting on this, it's maybe because I got "bitten" before (with the suspend), but what other examples do we have where, silently, instructions don't get executed after a call?

If I read correctly, @zmodem said he'd like to mention this in the doc or check it by assertions or verifiers. So it looks consensus to me?

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


More information about the llvm-commits mailing list