================
@@ -929,6 +932,17 @@ mlir::Value
CIRAttrToValue::visitCirAttr(cir::ConstArrayAttr attr) {
// Iteratively lower each constant element of the array.
if (auto arrayAttr = mlir::dyn_cast<mlir::ArrayAttr>(attr.getElts())) {
+ // Fewer struct members than elements: adjustGlobalTypeForInit grouped the
+ // elements of an array ending in many zeros into one leading array.
+ auto structTy = mlir::dyn_cast<mlir::LLVM::LLVMStructType>(llvmTy);
+ if (structTy && structTy.getBody().size() < arrayAttr.size()) {
+ auto arrayTy = mlir::cast<cir::ArrayType>(attr.getType());
+ auto prefix = cir::ConstArrayAttr::get(
+ cir::ArrayType::get(arrayTy.getElementType(), arrayAttr.size()),
+ arrayAttr);
+ return mlir::LLVM::InsertValueOp::create(rewriter, loc, result,
----------------
erichkeane wrote:
Ok, cool! Glad to see it isn't meaningfully different.
I'll do 1 more pass on this Monday if you don't mind, and get you an approve
then (barring other concerns).
https://github.com/llvm/llvm-project/pull/232835
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits