================
@@ -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,
----------------
koparasy wrote:
sounds good. I will get numbers.
https://github.com/llvm/llvm-project/pull/232835
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits