[clang] [CIR] Upstream initial for-loop support (PR #132266)

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 20 14:29:47 PDT 2025


================
@@ -52,6 +52,15 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
     return cir::BoolAttr::get(getContext(), getBoolTy(), state);
   }
 
+  /// Create a for operation.
+  cir::ForOp createFor(
+      mlir::Location loc,
+      llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)> condBuilder,
----------------
bcardosolopes wrote:

The initialization happens within the scope preceding the actual cir.for, etc. We have no intend of reproducing the AST 100% here, because of nested regions the alloca needs to be visible and dominate all the loop.

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


More information about the cfe-commits mailing list