forked from OSchip/llvm-project
[mlir][pdl] OperationOp should not be side-effect free
Unbound OperationOp in the matcher (i.e. one with no uses) is already disallowed by the verifier. However, an OperationOp in the rewriter is not side-effect free -- it's creating an op! Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D117825
This commit is contained in:
parent
d0cace5087
commit
7c471b56f2
|
@ -268,8 +268,7 @@ def PDL_OperandsOp
|
|||
// pdl::OperationOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def PDL_OperationOp
|
||||
: PDL_Op<"operation", [AttrSizedOperandSegments, NoSideEffect]> {
|
||||
def PDL_OperationOp : PDL_Op<"operation", [AttrSizedOperandSegments]> {
|
||||
let summary = "Define an operation within a pattern";
|
||||
let description = [{
|
||||
`pdl.operation` operations define operation nodes within a pattern. Within
|
||||
|
|
|
@ -202,3 +202,21 @@ module @apply_native_rewrite {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// CHECK-LABEL: module @unbound_rewrite_op
|
||||
module @unbound_rewrite_op {
|
||||
// CHECK: module @rewriters
|
||||
// CHECK: func @pdl_generated_rewriter()
|
||||
// CHECK: %[[UNUSED:.*]] = pdl_interp.create_operation "bar.op"
|
||||
// CHECK: pdl_interp.finalize
|
||||
pdl.pattern : benefit(1) {
|
||||
%root = pdl.operation "foo.op"
|
||||
pdl.rewrite %root {
|
||||
%unused = pdl.operation "bar.op"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// RUN: mlir-opt -canonicalize %s | FileCheck %s
|
||||
|
||||
pdl.pattern @operation_op : benefit(1) {
|
||||
%root = pdl.operation "foo.op"
|
||||
pdl.rewrite %root {
|
||||
// CHECK: pdl.operation "bar.unused"
|
||||
%unused_rewrite = pdl.operation "bar.unused"
|
||||
pdl.erase %root
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue