================
@@ -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:
Ran it: replayed all 6,672 TUs of a self-build. I have a python script that
goes over compile_commands.json with -fclangir, with and without this PR, OG
runs as noise floor.
Total CIR CPU 48,672s → 48,646s (0.999×); per-TU on/off distribution matches OG
noise.
I added a fixme in the last commit. I will merge this in if no objections
sometime next week.
https://github.com/llvm/llvm-project/pull/232835
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits