1 // RUN: mlir-opt %s -test-side-effects -verify-diagnostics
3 func.func @side_effect(%arg : index) {
4 // expected-remark@+1 {{operation has no memory effects}}
5 %0 = "test.side_effect_op"() {} : () -> i32
7 // expected-remark@+2 {{found an instance of 'read' on resource '<Default>'}}
8 // expected-remark@+1 {{found an instance of 'free' on resource '<Default>'}}
9 %1 = "test.side_effect_op"() {effects = [
10 {effect="read"}, {effect="free"}
13 // expected-remark@+1 {{found an instance of 'write' on resource '<Test>'}}
14 %2 = "test.side_effect_op"() {effects = [
15 {effect="write", test_resource}
18 // expected-remark@+1 {{found an instance of 'allocate' on a op result, on resource '<Test>'}}
19 %3 = "test.side_effect_op"() {effects = [
20 {effect="allocate", on_result, test_resource}
23 // expected-remark@+1 {{found an instance of 'read' on a symbol '@foo_ref', on resource '<Test>'}}
24 "test.side_effect_op"() {effects = [
25 {effect="read", on_reference = @foo_ref, test_resource}
28 // No _memory_ effects, but a parametric test effect.
29 // expected-remark@+2 {{operation has no memory effects}}
30 // expected-remark@+1 {{found a parametric effect with affine_map<(d0, d1) -> (d1, d0)>}}
31 %4 = "test.side_effect_op"() {
32 effect_parameter = affine_map<(i, j) -> (j, i)>
35 // Check with this unregistered operation to test the fallback on the dialect.
36 // expected-remark@+1 {{found a parametric effect with affine_map<(d0, d1) -> (d1, d0)>}}
37 %5 = "test.unregistered_side_effect_op"() {
38 effect_parameter = affine_map<(i, j) -> (j, i)>
41 // expected-remark@+1 {{found an instance of 'allocate' on a op operand, on resource '<Test>'}}
42 %6 = test.side_effect_with_region_op (%arg) {
44 test.region_yield %arg0 : index
45 } {effects = [ {effect="allocate", on_operand, test_resource} ]} : index -> index
47 // expected-remark@+1 {{found an instance of 'allocate' on a op result, on resource '<Test>'}}
48 %7 = test.side_effect_with_region_op (%arg) {
50 test.region_yield %arg0 : index
51 } {effects = [ {effect="allocate", on_result, test_resource} ]} : index -> index
53 // expected-remark@+1 {{found an instance of 'allocate' on a block argument, on resource '<Test>'}}
54 %8 = test.side_effect_with_region_op (%arg) {
56 test.region_yield %arg0 : index
57 } {effects = [ {effect="allocate", on_argument, test_resource} ]} : index -> index