================
@@ -300,27 +303,103 @@ static void emitCleanup(CIRGenFunction &cgf, 
cir::CleanupScopeOp cleanupScope,
   }
 }
 
-void CIRGenFunction::popCleanupBlock() {
+/// Check whether a cleanup scope body contains any non-yield exits that branch
+/// through the cleanup. These exits branch through the cleanup and require
+/// the normal cleanup to be executed even when the cleanup has been
+/// deactivated.
+static bool bodyHasBranchThroughExits(mlir::Region &bodyRegion) {
+  bool found = false;
+  bodyRegion.walk([&](mlir::Operation *op) {
+    if (isa<cir::ReturnOp, cir::GotoOp>(op))
+      found = true;
+  });
+  return found;
----------------
xlauko wrote:

```suggestion
  bool found = false;
  return bodyRegion.walk([&](mlir::Operation *op) {
    if (isa<cir::ReturnOp, cir::GotoOp>(op))
      return mlir::WalkResult::interupt();
  }).wasInterrupted();
```

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

Reply via email to