[Mlir-commits] [mlir] [mlir][memref] Fix segfault in SROA. (PR #71063)
Théo Degioanni
llvmlistbot at llvm.org
Fri Nov 3 12:27:13 PDT 2023
================
@@ -187,14 +187,28 @@ DeletionKind memref::LoadOp::removeBlockingUses(
return DeletionKind::Delete;
}
-/// Returns the index of a memref in attribute form, given its indices.
+/// Returns the index of a memref in attribute form, given its indices. Returns
+/// a null pointer if whether the indices form a valid index for the provided
+/// MemRefType cannot be computed.
static Attribute getAttributeIndexFromIndexOperands(MLIRContext *ctx,
- ValueRange indices) {
+ ValueRange indices,
+ MemRefType memrefType) {
+ ArrayRef<int64_t> shape = memrefType.getShape();
+ if (indices.size() != memrefType.getShape().size())
+ return {};
SmallVector<Attribute> index;
- for (Value coord : indices) {
+ for (size_t i = 0; i < shape.size(); i++) {
+ Value coord = indices[i];
+ int64_t dimSize = shape[i];
IntegerAttr coordAttr;
if (!matchPattern(coord, m_Constant<IntegerAttr>(&coordAttr)))
return {};
+ if (!coordAttr.getType().isIndex())
+ return {};
----------------
Moxinilian wrote:
Not being an index is an issue. But that is also covered by the verifier.
https://github.com/llvm/llvm-project/pull/71063
More information about the Mlir-commits
mailing list