[clang] [CIR] [Upstream local initialization for ArrayType (PR #132974)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 26 15:07:41 PDT 2025


================
@@ -658,6 +742,27 @@ mlir::LogicalResult CIRToLLVMConstantOpLowering::matchAndRewrite(
     }
     assert(!cir::MissingFeatures::opGlobalViewAttr());
     attr = op.getValue();
+  } else if (const auto arrTy = mlir::dyn_cast<cir::ArrayType>(op.getType())) {
+    const auto constArr = mlir::dyn_cast<cir::ConstArrayAttr>(op.getValue());
+    if (!constArr && !isa<cir::ZeroAttr, cir::UndefAttr>(op.getValue()))
+      return op.emitError() << "array does not have a constant initializer";
+
+    std::optional<mlir::Attribute> denseAttr;
+    if (constArr && hasTrailingZeros(constArr)) {
+      const mlir::Value newOp = lowerCirAttrAsValue(
+          op, constArr, rewriter, getTypeConverter(), dataLayout);
----------------
andykaylor wrote:

```suggestion
          op, constArr, rewriter, getTypeConverter());
```

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


More information about the cfe-commits mailing list