[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
Fri May 3 06:57:44 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:

That still sounds like the remark would not target the compiler user, but the developer of the compiler tool -- and that's not really what optimization remarks are for.

The more I think about this, the less I like the idea of a remark. A "deleted instructions after llvm.coro.await.suspend.handle call" remark would be pure noise for a normal optimization remarks user. Plus we would need to maintain the code which to emit it, including tests for when it should trigger or not.

I think my patch makes the semantic of llvm.coro.await.suspend.handle clear in the doc, I think that behavior is compatible with how calls in the IR already works, and I think existing passes will handle it well. I don't think it needs special handling.

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


More information about the llvm-commits mailing list