1// RUN: mlir-opt %s -pass-pipeline='module(test-module-pass,func(test-function-pass)),func(test-function-pass)' -pass-pipeline="func(cse,canonicalize)" -verify-each=false -pass-timing -pass-timing-display=pipeline 2>&1 | FileCheck %s
2// RUN: mlir-opt %s -test-textual-pm-nested-pipeline -verify-each=false -pass-timing -pass-timing-display=pipeline 2>&1 | FileCheck %s --check-prefix=TEXTUAL_CHECK
3// RUN: not mlir-opt %s -pass-pipeline='module(test-module-pass' 2>&1 | FileCheck --check-prefix=CHECK_ERROR_1 %s
4// RUN: not mlir-opt %s -pass-pipeline='module(test-module-pass))' 2>&1 | FileCheck --check-prefix=CHECK_ERROR_2 %s
5// RUN: not mlir-opt %s -pass-pipeline='module()(' 2>&1 | FileCheck --check-prefix=CHECK_ERROR_3 %s
6// RUN: not mlir-opt %s -pass-pipeline=',' 2>&1 | FileCheck --check-prefix=CHECK_ERROR_4 %s
7// RUN: not mlir-opt %s -pass-pipeline='func(test-module-pass)' 2>&1 | FileCheck --check-prefix=CHECK_ERROR_5 %s
8
9// CHECK_ERROR_1: encountered unbalanced parentheses while parsing pipeline
10// CHECK_ERROR_2: encountered extra closing ')' creating unbalanced parentheses while parsing pipeline
11// CHECK_ERROR_3: expected ',' after parsing pipeline
12// CHECK_ERROR_4: does not refer to a registered pass or pass pipeline
13// CHECK_ERROR_5:  Can't add pass '{{.*}}TestModulePass' restricted to 'module' on a PassManager intended to run on 'func', did you intend to nest?
14func @foo() {
15  return
16}
17
18module {
19  func @foo() {
20    return
21  }
22}
23
24// CHECK: Pipeline Collection : ['func', 'module']
25// CHECK-NEXT:   'func' Pipeline
26// CHECK-NEXT:     TestFunctionPass
27// CHECK-NEXT:     CSE
28// CHECK-NEXT:       DominanceInfo
29// CHECK-NEXT:     Canonicalizer
30// CHECK-NEXT:   'module' Pipeline
31// CHECK-NEXT:     TestModulePass
32// CHECK-NEXT:     'func' Pipeline
33// CHECK-NEXT:       TestFunctionPass
34
35// TEXTUAL_CHECK: Pipeline Collection : ['func', 'module']
36// TEXTUAL_CHECK-NEXT:   'func' Pipeline
37// TEXTUAL_CHECK-NEXT:     TestFunctionPass
38// TEXTUAL_CHECK-NEXT:   'module' Pipeline
39// TEXTUAL_CHECK-NEXT:     TestModulePass
40// TEXTUAL_CHECK-NEXT:     'func' Pipeline
41// TEXTUAL_CHECK-NEXT:       TestFunctionPass
42