[Mlir-commits] [mlir] [mlir][bufferization] Buffer deallocation: Make op preconditions stricter (PR #75127)

Aart Bik llvmlistbot at llvm.org
Fri Jan 19 09:42:53 PST 2024


================
@@ -48,6 +48,32 @@ static Value buildBoolValue(OpBuilder &builder, Location loc, bool value) {
 
 static bool isMemref(Value v) { return v.getType().isa<BaseMemRefType>(); }
 
+/// Return "true" if the given op is guaranteed to have no "Allocate" or "Free"
+/// side effect.
+static bool hasNoAllocateOrFreeSideEffect(Operation *op) {
+  if (isa<MemoryEffectOpInterface>(op))
+    return hasEffect<MemoryEffects::Allocate>(op) ||
+           hasEffect<MemoryEffects::Free>(op);
+  // If the op does not implement the MemoryEffectOpInterface but has has
+  // recursive memory effects, then this op in isolation (without its body) does
+  // not have any side effects. The ops inside the regions of this op will be
----------------
aartbik wrote:

All the ops inside the regions ....
(reads a bit better?)

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


More information about the Mlir-commits mailing list