[Mlir-commits] [mlir] [mlir][bufferization][NFC] Simplify helper `potentiallyAliasesMemref` (PR #78690)

Martin Erhart llvmlistbot at llvm.org
Fri Jan 19 03:40:38 PST 2024


================
@@ -314,11 +308,13 @@ struct SplitDeallocWhenNotAliasingAnyOther
 
     SmallVector<Value> remainingMemrefs, remainingConditions;
     SmallVector<SmallVector<Value>> updatedConditions;
-    for (auto [memref, cond] :
-         llvm::zip(deallocOp.getMemrefs(), deallocOp.getConditions())) {
+    for (int64_t i = 0, e = deallocOp.getMemrefs().size(); i < e; ++i) {
+      Value memref = deallocOp.getMemrefs()[i];
+      Value cond = deallocOp.getConditions()[i];
+      SmallVector<Value> otherMemrefs(deallocOp.getMemrefs());
+      otherMemrefs.erase(otherMemrefs.begin() + i);
----------------
maerhart wrote:

This probably even fixes a bug when the same memref is contained in `deallocOp.getMemrefs()` multiple times. The old implementation would allow splitting which would lead to a double-free if I understand correctly without actually testing it or looking into it in detail. Do we have a test-case for that?

https://github.com/llvm/llvm-project/pull/78690


More information about the Mlir-commits mailing list