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

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 29 11:35:12 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
----------------
zmodem wrote:

I want the semantics to be well specified. Either the doc for this intrinsic should say that instructions between it and `llvm.coro.suspend` are not allowed (possibly with a list of exceptions) and we enforce it with an assert or the verifier; or it allows such instructions but says that they become unreachable as in the current version.

I'm in favor of the latter because it makes the IR more regular. We generally don't impose restrictions about what instructions are allowed between intrinsic calls. Instructions after a call not getting executed is not new, so I think what the current version of the patch does fits in well with the IR.

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


More information about the llvm-commits mailing list