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

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 29 10:01:28 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
----------------
mtrofin wrote:

It's not about legality, it's about the fact they wouldn't be executed being a symptom of a bug - e.g. earlier pass (like coverage) believing there is something to cover while there isn't. We could at minimum have some "under build with asserts" behavior that (except for trivial cases like debug/lifetime instructions) says something. 

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


More information about the llvm-commits mailing list