================
@@ -725,21 +725,105 @@ class CIRTernaryOpFlattening : public 
mlir::OpRewritePattern<cir::TernaryOp> {
   }
 };
 
+// Get or create the cleanup destination slot for a function. This slot is
+// shared across all cleanup scopes in the function to track which exit path
+// to take after running cleanup code when there are multiple exits.
+static cir::AllocaOp getOrCreateCleanupDestSlot(cir::FuncOp funcOp,
+                                                mlir::PatternRewriter 
&rewriter,
+                                                mlir::Location loc) {
+  mlir::Block &entryBlock = funcOp.getBody().front();
+
+  // Look for an existing cleanup dest slot in the entry block.
+  for (auto &op : entryBlock) {
+    if (auto existingAlloca = dyn_cast<cir::AllocaOp>(&op)) {
+      if (existingAlloca.getName() == "__cleanup_dest_slot")
----------------
erichkeane wrote:

Could this all be a llvm::find_if kinda thing? 

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

Reply via email to