[Mlir-commits] [mlir] 76f097c - [mlir] Ensure index attrs are always 64-bit APInts
Jeff Niu
llvmlistbot at llvm.org
Wed Aug 31 15:44:29 PDT 2022
Author: Jeff Niu
Date: 2022-08-31T15:44:18-07:00
New Revision: 76f097cf147277e0721d3173684cef0e563a2b71
URL: https://github.com/llvm/llvm-project/commit/76f097cf147277e0721d3173684cef0e563a2b71
DIFF: https://github.com/llvm/llvm-project/commit/76f097cf147277e0721d3173684cef0e563a2b71.diff
LOG: [mlir] Ensure index attrs are always 64-bit APInts
This patch ensures that index integer attributes can only be
constructed with APInts whose widths are equal to the index
internal storage bitwidth (64).
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D133059
Added:
Modified:
mlir/lib/IR/BuiltinAttributes.cpp
Removed:
################################################################################
diff --git a/mlir/lib/IR/BuiltinAttributes.cpp b/mlir/lib/IR/BuiltinAttributes.cpp
index da7e694e7459d..810672e3d7ed3 100644
--- a/mlir/lib/IR/BuiltinAttributes.cpp
+++ b/mlir/lib/IR/BuiltinAttributes.cpp
@@ -435,8 +435,14 @@ LogicalResult IntegerAttr::verify(function_ref<InFlightDiagnostic()> emitError,
<< value.getBitWidth() << ")";
return success();
}
- if (type.isa<IndexType>())
+ if (type.isa<IndexType>()) {
+ if (value.getBitWidth() != IndexType::kInternalStorageBitWidth)
+ return emitError()
+ << "value bit width (" << value.getBitWidth()
+ << ") doesn't match index type internal storage bit width ("
+ << IndexType::kInternalStorageBitWidth << ")";
return success();
+ }
return emitError() << "expected integer or index type";
}
More information about the Mlir-commits
mailing list