xref: /llvm-project/mlir/test/Pass/action-logging-filter.mlir (revision 87e6e490e79384a523bc7f0216c3db60227d6d58)
1// Run the canonicalize on each function, use the --log-mlir-actions-filter= option
2// to filter which action should be logged.
3
4func.func @a() {
5    return
6}
7
8func.func @b() {
9    return
10}
11
12func.func @c() {
13    return
14}
15
16////////////////////////////////////
17/// 1. All actions should be logged.
18
19// RUN: mlir-opt %s --log-actions-to=- -pass-pipeline="builtin.module(func.func(test-stats-pass))" -o %t --mlir-disable-threading | FileCheck %s
20// Specify the current file as filter, expect to see all actions.
21// RUN: mlir-opt %s --log-mlir-actions-filter=%s --log-actions-to=- -pass-pipeline="builtin.module(func.func(test-stats-pass))" -o %t --mlir-disable-threading | FileCheck %s
22
23// CHECK: [thread {{.*}}] begins (no breakpoint) Action `pass-execution`  running `{{.*}}TestStatisticPass` on Operation `func.func` (func.func @a() {...}
24// CHECK-NEXT: [thread {{.*}}] completed `pass-execution`
25// CHECK-NEXT: [thread {{.*}}] begins (no breakpoint) Action `pass-execution`  running `{{.*}}TestStatisticPass` on Operation `func.func` (func.func @b() {...}
26// CHECK-NEXT: [thread {{.*}}] completed `pass-execution`
27// CHECK-NEXT: [thread {{.*}}] begins (no breakpoint) Action `pass-execution`  running `{{.*}}TestStatisticPass` on Operation `func.func` (func.func @c() {...}
28// CHECK-NEXT: [thread {{.*}}] completed `pass-execution`
29
30////////////////////////////////////
31/// 2. No match
32
33// Specify a non-existing file as filter, expect to see no actions.
34// RUN: mlir-opt %s --log-mlir-actions-filter=foo.mlir --log-actions-to=- -pass-pipeline="builtin.module(func.func(test-stats-pass))" -o %t --mlir-disable-threading | FileCheck %s --check-prefix=CHECK-NONE --allow-empty
35// Filter on a non-matching line, expect to see no actions.
36// RUN: mlir-opt %s --log-mlir-actions-filter=%s:1 --log-actions-to=- -pass-pipeline="builtin.module(func.func(test-stats-pass))" -o %t --mlir-disable-threading | FileCheck %s --check-prefix=CHECK-NONE --allow-empty
37
38// Invalid Filter
39// CHECK-NONE-NOT: Canonicalizer
40
41////////////////////////////////////
42/// 3. Matching filters
43
44// Filter the second function only
45// RUN: mlir-opt %s --log-mlir-actions-filter=%s:8 --log-actions-to=- -pass-pipeline="builtin.module(func.func(test-stats-pass))" -o %t --mlir-disable-threading | FileCheck %s --check-prefix=CHECK-SECOND
46
47// CHECK-SECOND-NOT: @a
48// CHECK-SECOND-NOT: @c
49// CHECK-SECOND: [thread {{.*}}] begins (no breakpoint) Action `pass-execution`  running `{{.*}}TestStatisticPass` on Operation `func.func` (func.func @b() {...}
50// CHECK-SECOND-NEXT: [thread {{.*}}] completed `pass-execution`
51
52// Filter the first and third functions
53// RUN: mlir-opt %s --log-mlir-actions-filter=%s:4,%s:12 --log-actions-to=- -pass-pipeline="builtin.module(func.func(test-stats-pass))" -o %t --mlir-disable-threading | FileCheck %s  --check-prefix=CHECK-FIRST-THIRD
54
55// CHECK-FIRST-THIRD-NOT: Canonicalizer
56// CHECK-FIRST-THIRD: [thread {{.*}}] begins (no breakpoint) Action `pass-execution`  running `{{.*}}TestStatisticPass` on Operation `func.func` (func.func @a() {...}
57// CHECK-FIRST-THIRD-NEXT: [thread {{.*}}] completed `pass-execution`
58// CHECK-FIRST-THIRD-NEXT: [thread {{.*}}] begins (no breakpoint) Action `pass-execution`  running `{{.*}}TestStatisticPass` on Operation `func.func` (func.func @c() {...}
59// CHECK-FIRST-THIRD-NEXT: [thread {{.*}}] completed `pass-execution`
60// CHECK-FIRST-THIRD-NOT: Canonicalizer
61