[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 07:50:23 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'm hesitant to add such a check. I don't think it should be illegal to have instructions after the llvm.coro.await.suspend.handle call, the semantics is just that those instructions won't execute -- similarly to how instructions after other function calls may not run. For example one could imagine some kind of coverage instrumentation or debug intrinsics or whatnot; those would not run, meaning that code path wasn't taken.

For the PGO issue, if I understand correctly the issue was that it prevented the musttail lowering, which won't happen anymore.

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


More information about the llvm-commits mailing list