1 // RUN: mlir-opt -test-generic-ir-visitors-interrupt -allow-unregistered-dialect -split-input-file %s | FileCheck %s
3 // Walk is interrupted before visiting "foo"
4 func.func @main(%arg0: f32) -> f32 {
5 %v1 = "foo"() {interrupt_before_all = true} : () -> f32
6 %v2 = arith.addf %v1, %arg0 : f32
10 // CHECK: step 0 op 'builtin.module' before all regions
11 // CHECK: step 1 op 'func.func' before all regions
12 // CHECK: step 2 walk was interrupted
16 // Walk is interrupted after visiting "foo" (which has a single empty region)
17 func.func @main(%arg0: f32) -> f32 {
18 %v1 = "foo"() ({ "bar"() : ()-> () }) {interrupt_after_all = true} : () -> f32
19 %v2 = arith.addf %v1, %arg0 : f32
23 // CHECK: step 0 op 'builtin.module' before all regions
24 // CHECK: step 1 op 'func.func' before all regions
25 // CHECK: step 2 op 'foo' before all regions
26 // CHECK: step 3 op 'bar' before all regions
27 // CHECK: step 4 walk was interrupted
31 // Walk is interrupted after visiting "foo"'s 1st region.
32 func.func @main(%arg0: f32) -> f32 {
37 }) {interrupt_after_region = 0} : () -> f32
38 %v2 = arith.addf %v1, %arg0 : f32
42 // CHECK: step 0 op 'builtin.module' before all regions
43 // CHECK: step 1 op 'func.func' before all regions
44 // CHECK: step 2 op 'foo' before all regions
45 // CHECK: step 3 op 'bar0' before all regions
46 // CHECK: step 4 walk was interrupted
51 // Test static filtering.
54 "test.two_region_op"()(
55 {"work"() : () -> ()},
57 ) {interrupt_after_all = true} : () -> ()
61 // CHECK: step 0 op 'builtin.module' before all regions
62 // CHECK: step 1 op 'func.func' before all regions
63 // CHECK: step 2 op 'foo' before all regions
64 // CHECK: step 3 op 'test.two_region_op' before all regions
65 // CHECK: step 4 op 'work' before all regions
66 // CHECK: step 5 op 'test.two_region_op' before region #1
67 // CHECK: step 6 op 'work' before all regions
68 // CHECK: step 7 walk was interrupted
69 // CHECK: step 8 op 'test.two_region_op' before all regions
70 // CHECK: step 9 op 'test.two_region_op' before region #1
71 // CHECK: step 10 walk was interrupted
75 // Test static filtering.
78 "test.two_region_op"()(
79 {"work"() : () -> ()},
81 ) {interrupt_after_region = 0} : () -> ()
85 // CHECK: step 0 op 'builtin.module' before all regions
86 // CHECK: step 1 op 'func.func' before all regions
87 // CHECK: step 2 op 'foo' before all regions
88 // CHECK: step 3 op 'test.two_region_op' before all regions
89 // CHECK: step 4 op 'work' before all regions
90 // CHECK: step 5 walk was interrupted
91 // CHECK: step 6 op 'test.two_region_op' before all regions
92 // CHECK: step 7 walk was interrupted
97 // Walk is skipped before visiting "foo".
98 func.func @main(%arg0: f32) -> f32 {
103 }) {skip_before_all = true} : () -> f32
104 %v2 = arith.addf %v1, %arg0 : f32
108 // CHECK: step 0 op 'builtin.module' before all regions
109 // CHECK: step 1 op 'func.func' before all regions
110 // CHECK: step 2 op 'arith.addf' before all regions
111 // CHECK: step 3 op 'func.return' before all regions
112 // CHECK: step 4 op 'func.func' after all regions
113 // CHECK: step 5 op 'builtin.module' after all regions
116 // Walk is skipped after visiting all regions of "foo".
117 func.func @main(%arg0: f32) -> f32 {
122 }) {skip_after_all = true} : () -> f32
123 %v2 = arith.addf %v1, %arg0 : f32
127 // CHECK: step 0 op 'builtin.module' before all regions
128 // CHECK: step 1 op 'func.func' before all regions
129 // CHECK: step 2 op 'foo' before all regions
130 // CHECK: step 3 op 'bar0' before all regions
131 // CHECK: step 4 op 'foo' before region #1
132 // CHECK: step 5 op 'bar1' before all regions
133 // CHECK: step 6 op 'arith.addf' before all regions
134 // CHECK: step 7 op 'func.return' before all regions
135 // CHECK: step 8 op 'func.func' after all regions
136 // CHECK: step 9 op 'builtin.module' after all regions
139 // Walk is skipped after visiting first region of "foo".
140 func.func @main(%arg0: f32) -> f32 {
145 }) {skip_after_region = 0} : () -> f32
146 %v2 = arith.addf %v1, %arg0 : f32
150 // CHECK: step 0 op 'builtin.module' before all regions
151 // CHECK: step 1 op 'func.func' before all regions
152 // CHECK: step 2 op 'foo' before all regions
153 // CHECK: step 3 op 'bar0' before all regions
154 // CHECK: step 4 op 'arith.addf' before all regions
155 // CHECK: step 5 op 'func.return' before all regions
156 // CHECK: step 6 op 'func.func' after all regions
157 // CHECK: step 7 op 'builtin.module' after all regions