diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td --- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td +++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td @@ -167,7 +167,7 @@ def Bufferization_CloneOp : Bufferization_Op<"clone", [ CopyOpInterface, - DeclareOpInterfaceMethods, + MemoryEffectsOpInterface, DeclareOpInterfaceMethods ]> { let builders = [ @@ -191,8 +191,11 @@ behavior. }]; - let arguments = (ins Arg:$input); - let results = (outs Arg:$output); + let arguments = (ins Arg]>:$input); + let results = (outs Res, + MemAlloc]>:$output); let extraClassDeclaration = [{ Value getSource() { return getInput(); } diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp --- a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp +++ b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp @@ -489,17 +489,6 @@ // CloneOp //===----------------------------------------------------------------------===// -void CloneOp::getEffects( - SmallVectorImpl> - &effects) { - effects.emplace_back(MemoryEffects::Read::get(), getInput(), - SideEffects::DefaultResource::get()); - effects.emplace_back(MemoryEffects::Write::get(), getOutput(), - SideEffects::DefaultResource::get()); - effects.emplace_back(MemoryEffects::Allocate::get(), getOutput(), - SideEffects::DefaultResource::get()); -} - OpFoldResult CloneOp::fold(FoldAdaptor adaptor) { return succeeded(memref::foldMemRefCast(*this)) ? getResult() : Value(); } diff --git a/mlir/test/Dialect/Bufferization/side-effects.mlir b/mlir/test/Dialect/Bufferization/side-effects.mlir new file mode 100644 --- /dev/null +++ b/mlir/test/Dialect/Bufferization/side-effects.mlir @@ -0,0 +1,10 @@ +// RUN: mlir-opt %s --test-side-effects --verify-diagnostics + +func.func @test_side_effects(%arg0: memref<2xi32>) -> memref<2xi32> { + // expected-remark @below {{found an instance of 'read' on a value, on resource ''}} + // expected-remark @below {{found an instance of 'write' on a value, on resource ''}} + // expected-remark @below {{found an instance of 'allocate' on a value, on resource ''}} + %0 = bufferization.clone %arg0 : memref<2xi32> to memref<2xi32> + // expected-remark @below {{operation has no memory effects}} + return %0 : memref<2xi32> +}