[Mlir-commits] [mlir] [mlir][memref] Fix segfault in SROA. (PR #71063)
Théo Degioanni
llvmlistbot at llvm.org
Fri Nov 3 12:26:32 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 {};
----------------
Moxinilian wrote:
Yes, it's just a matter of whether or not we assume `getAttributeIndexFromIndexOperands` takes operands from LoadOp and StoreOp. This is probably a safe assumption, if documented.
https://github.com/llvm/llvm-project/pull/71063
More information about the Mlir-commits
mailing list