llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Artemiy (NotLebedev) <details> <summary>Changes</summary> Closes #<!-- -->187699 . Fix incorrect parsing of `ConstArrayAttr`. `parse` method incorrectly used type of `elts` parameter as type of the whole array. This means that when reading back text or bytecode clangir files attribute did not have correct type and correct `trailingZerosNum`. Type was always of inner `elts`, meaning smaller then actual type if any trailing zeros were present and `trailingZerosNum` was always zero. --- Full diff: https://github.com/llvm/llvm-project/pull/188742.diff 1 Files Affected: - (modified) clang/lib/CIR/Dialect/IR/CIRAttrs.cpp (+6-7) ``````````diff diff --git a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp index d608038dafc5f..27cba6a20b445 100644 --- a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp @@ -616,13 +616,12 @@ Attribute ConstArrayAttr::parse(AsmParser &parser, Type type) { unsigned zeros = 0; if (parser.parseOptionalComma().succeeded()) { if (parser.parseOptionalKeyword("trailing_zeros").succeeded()) { - unsigned typeSize = - mlir::cast<cir::ArrayType>(resultTy.value()).getSize(); + unsigned totalSize = mlir::cast<cir::ArrayType>(type).getSize(); mlir::Attribute elts = resultVal.value(); if (auto str = mlir::dyn_cast<mlir::StringAttr>(elts)) - zeros = typeSize - str.size(); + zeros = totalSize - str.size(); else - zeros = typeSize - mlir::cast<mlir::ArrayAttr>(elts).size(); + zeros = totalSize - mlir::cast<mlir::ArrayAttr>(elts).size(); } else { return {}; } @@ -632,9 +631,9 @@ Attribute ConstArrayAttr::parse(AsmParser &parser, Type type) { if (parser.parseGreater()) return {}; - return parser.getChecked<ConstArrayAttr>( - parser.getCurrentLocation(), parser.getContext(), resultTy.value(), - resultVal.value(), zeros); + return parser.getChecked<ConstArrayAttr>(parser.getCurrentLocation(), + parser.getContext(), type, + resultVal.value(), zeros); } void ConstArrayAttr::print(AsmPrinter &printer) const { `````````` </details> https://github.com/llvm/llvm-project/pull/188742 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
