[Mlir-commits] [mlir] 2562991 - [mlir] fix ubsan when loading array<i0>
Jeff Niu
llvmlistbot at llvm.org
Thu Sep 1 09:50:18 PDT 2022
Author: Jeff Niu
Date: 2022-09-01T09:50:01-07:00
New Revision: 2562991c36fc486778f68a01c684589fa26beee2
URL: https://github.com/llvm/llvm-project/commit/2562991c36fc486778f68a01c684589fa26beee2
DIFF: https://github.com/llvm/llvm-project/commit/2562991c36fc486778f68a01c684589fa26beee2.diff
LOG: [mlir] fix ubsan when loading array<i0>
Added:
Modified:
mlir/lib/IR/AsmPrinter.cpp
Removed:
################################################################################
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index fedb452aa2fc9..9cf9501850a6b 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -2044,9 +2044,11 @@ void AsmPrinter::Impl::printDenseArrayAttr(DenseArrayAttr attr) {
auto printElementAt = [&](unsigned i) {
APInt value(bitwidth, 0);
- llvm::LoadIntFromMemory(
- value, reinterpret_cast<const uint8_t *>(data.begin() + byteSize * i),
- byteSize);
+ if (bitwidth) {
+ llvm::LoadIntFromMemory(
+ value, reinterpret_cast<const uint8_t *>(data.begin() + byteSize * i),
+ byteSize);
+ }
// Print the data as-is or as a float.
if (type.isIntOrIndex()) {
printDenseIntElement(value, getStream(), type);
More information about the Mlir-commits
mailing list