[clang-tools-extra] [llvm] [clang] [mlir] [mlir] Fix a zero stride canonicalizer crash (PR #74200)
Kai Sasaki via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 3 22:39:57 PST 2023
================
@@ -139,12 +139,36 @@ SmallVector<int64_t>
getValuesSortedByKey(ArrayRef<Attribute> keys, ArrayRef<int64_t> values,
llvm::function_ref<bool(Attribute, Attribute)> compare);
+/// Helper function to check whether the passed in `sizes` or `values` are
+/// valid. This can be used to re-check whether dimensions are still valid
+/// after constant folding the dynamic dimensions.
+bool hasValidSizesOffsets(SmallVector<int64_t> sizesOrOffsets);
+
+/// Helper function to check whether the passed in `strides` are valid. This
+/// can be used to re-check whether dimensions are still valid after constant
+/// folding the dynamic dimensions.
+bool hasValidStrides(SmallVector<int64_t> strides);
+
/// Returns "success" when any of the elements in `ofrs` is a constant value. In
/// that case the value is replaced by an attribute. Returns "failure" when no
-/// folding happened. If `onlyNonNegative` is set, only non-negative constant
-/// values are folded.
+/// folding happened. If `onlyNonNegative` and `onlyNonZero` are set, only
+/// non-negative and non-zero constant values are folded respectively.
LogicalResult foldDynamicIndexList(SmallVectorImpl<OpFoldResult> &ofrs,
- bool onlyNonNegative = false);
+ bool onlyNonNegative = false,
+ bool onlyNonZero = false);
+
+/// Returns "success" when any of the elements in `OffsetsOrSizes` is a
----------------
Lewuathe wrote:
```suggestion
/// Returns "success" when any of the elements in `offsetsOrSizes` is a
```
https://github.com/llvm/llvm-project/pull/74200
More information about the cfe-commits
mailing list