[clang] [CIR] Fix cleanup ordering of coroutines (PR #230574)

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 15 17:52:07 PDT 2026


================
@@ -3834,12 +3833,11 @@ void cir::CoroutineOp::getSuccessorRegions(
     return;
   }
 
-  // destroy has two possible outcomes depending on why it was entered:
-  // ordinary destroy dispatch falls through to exit (normal return); an
-  // exception that reached destroy needs to keep propagating instead, i.e.
-  // leave the whole op rather than go through exit's cir.return.
+  // destroy falls through to exit (normal return).
   if (parent == &getDestroy()) {
     regions.emplace_back(&getExit());
+    // Replace the parent edge with the unwind region once it is implemetend.
+    assert(!cir::MissingFeatures::coroUnwindRegion());
----------------
bcardosolopes wrote:

With the escaping-exception edge into `destroy` gone, and the op description now saying an exception must not reach `destroy`, this edge has no source anymore: `destroy` only ever falls through to `exit`. Please drop it. The `coroUnwindRegion` marker belongs where the exceptional exit from `body` will be modeled, not here. (Also "implemetend".)

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


More information about the cfe-commits mailing list