[Mlir-commits] [mlir] ded3644 - [MLIR][NFC] Fix a checked after used case in ReshapeOpsUtils.cpp
Shivam Gupta
llvmlistbot at llvm.org
Thu Jan 26 09:21:33 PST 2023
Author: Shivam Gupta
Date: 2023-01-26T22:51:51+05:30
New Revision: ded3644a3f8ef5c34a956267004bdd6e936bae18
URL: https://github.com/llvm/llvm-project/commit/ded3644a3f8ef5c34a956267004bdd6e936bae18
DIFF: https://github.com/llvm/llvm-project/commit/ded3644a3f8ef5c34a956267004bdd6e936bae18.diff
LOG: [MLIR][NFC] Fix a checked after used case in ReshapeOpsUtils.cpp
Found by PVS-Studio - https://pvs-studio.com/en/blog/posts/cpp/1003/, N18.
The value of the 'sourceDim' index is checked after it was used.
Reviewed By: zero9178
Differential Revision: https://reviews.llvm.org/D142312
Added:
Modified:
mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp b/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
index fc11e814ef6c5..750c8f9ccb381 100644
--- a/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
+++ b/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp
@@ -47,9 +47,9 @@ mlir::getReassociationIndicesForCollapse(ArrayRef<int64_t> sourceShape,
break;
int64_t currTargetShape = targetShape[targetDim];
- while (sourceShape[sourceDim] != ShapedType::kDynamic &&
- prodOfCollapsedDims * sourceShape[sourceDim] < currTargetShape &&
- sourceDim < sourceShape.size()) {
+ while (sourceDim < sourceShape.size() &&
+ sourceShape[sourceDim] != ShapedType::kDynamic &&
+ prodOfCollapsedDims * sourceShape[sourceDim] < currTargetShape) {
prodOfCollapsedDims *= sourceShape[sourceDim];
currIndices.push_back(sourceDim++);
}
More information about the Mlir-commits
mailing list