================
@@ -973,8 +1028,27 @@ void CodeGenFunction::EmitCoroutineBody(const 
CoroutineBodyStmt &S) {
     // shouldn't change the AST.
     if (PreviousRetValue)
       cast<ReturnStmt>(Ret)->setRetValue(PreviousRetValue);
-  }
 
+    if (!GroManager.DirectEmit) {
+      // Send GRO conversion to ConvBB
+      auto *ConvBB =
+          cast<llvm::BranchInst>(PreConvBB->getTerminator())->getSuccessor(0);
+      auto FromIt = ++RetBB->getFirstInsertionPt();
+      auto ToIt = RetBB->getTerminator()->getIterator();
+      ConvBB->splice(ConvBB->getFirstNonPHIIt(), RetBB, FromIt, ToIt);
+
+      // After gro conversion, destroy the coroutine if it finishes execution.
+      BasicBlock *AfterConvBB =
+          cast<llvm::BranchInst>(PreConvBB->getTerminator())->getSuccessor(1);
+      BasicBlock *CleanupBB = AfterConvBB->getSingleSuccessor();
----------------
NewSigma wrote:

Thanks for highlighting that. In this revision, I handle `AfterConvBB` directly 
within `EmitGroConv`, rather than inferring its successor. This approach makes 
the logic explicit and we do not have to record `AfterConvBB`.

https://github.com/llvm/llvm-project/pull/151067
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to