-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[mlir][transform] Fix Wtype-limits warning #146898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
``` warning: comparison of unsigned expression in ‘< 0’ is always false [-Wtype-limits] ``` `size_t` is unsigned and always non-negative, whereas `getInt()` returns a signless `int64_t`. To ensure type compatibility and eliminate the warning, `dynamicOptionIdx` should be changed to `int64_t`.
|
@llvm/pr-subscribers-mlir Author: Longsheng Mou (CoTinker) Changes
Full diff: https://github.com/llvm/llvm-project/pull/146898.diff 1 Files Affected:
diff --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
index bb9bdd70625e4..0db0317461c03 100644
--- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
+++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
@@ -799,8 +799,8 @@ transform::ApplyRegisteredPassOp::apply(transform::TransformRewriter &rewriter,
if (auto paramOperand = dyn_cast<transform::ParamOperandAttr>(valueAttr)) {
// The corresponding value attribute(s) is/are passed in via a param.
// Obtain the param-operand via its specified index.
- size_t dynamicOptionIdx = paramOperand.getIndex().getInt();
- assert(dynamicOptionIdx < dynamicOptions.size() &&
+ int64_t dynamicOptionIdx = paramOperand.getIndex().getInt();
+ assert(dynamicOptionIdx < static_cast<int64_t>(dynamicOptions.size()) &&
"the number of ParamOperandAttrs in the options DictionaryAttr"
"should be the same as the number of options passed as params");
ArrayRef<Attribute> attrsAssociatedToParam =
@@ -1015,8 +1015,9 @@ LogicalResult transform::ApplyRegisteredPassOp::verify() {
std::function<LogicalResult(Attribute)> checkOptionValue =
[&](Attribute valueAttr) -> LogicalResult {
if (auto paramOperand = dyn_cast<transform::ParamOperandAttr>(valueAttr)) {
- size_t dynamicOptionIdx = paramOperand.getIndex().getInt();
- if (dynamicOptionIdx < 0 || dynamicOptionIdx >= dynamicOptions.size())
+ int64_t dynamicOptionIdx = paramOperand.getIndex().getInt();
+ if (dynamicOptionIdx < 0 ||
+ dynamicOptionIdx >= static_cast<int64_t>(dynamicOptions.size()))
return emitOpError()
<< "dynamic option index " << dynamicOptionIdx
<< " is out of bounds for the number of dynamic options: "
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/207/builds/3351 Here is the relevant piece of the build log for the reference |
size_tis unsigned and always non-negative, whereasgetInt()returns a signlessint64_t. To ensure type compatibility and eliminate the warning,dynamicOptionIdxshould be changed toint64_t.