xref: /llvm-project/flang/test/Driver/mlir-pass-pipeline.f90 (revision 3bb969f3ebb25037e8eb69c30a5a0dfb5d9d0f51)
1! Test the MLIR pass pipeline
2
3! RUN: %flang_fc1 -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline -o /dev/null %s 2>&1 | FileCheck --check-prefixes=ALL %s
4! -O0 is the default:
5! RUN: %flang_fc1 -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -O0 -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL %s
6! RUN: %flang_fc1 -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -O2 -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,O2 %s
7
8! REQUIRES: asserts
9
10end program
11
12! ALL: Pass statistics report
13! ALL: Fortran::lower::VerifierPass
14
15! ALL: Pass statistics report
16
17! ALL: Fortran::lower::VerifierPass
18! O2-NEXT: Canonicalizer
19! ALL:     Pipeline Collection : ['fir.global', 'func.func', 'omp.declare_reduction', 'omp.private']
20! ALL-NEXT:'fir.global' Pipeline
21! O2-NEXT:   SimplifyHLFIRIntrinsics
22! ALL:       InlineElementals
23! ALL-NEXT:'func.func' Pipeline
24! O2-NEXT:   SimplifyHLFIRIntrinsics
25! ALL:       InlineElementals
26! ALL-NEXT:'omp.declare_reduction' Pipeline
27! O2-NEXT:   SimplifyHLFIRIntrinsics
28! ALL:       InlineElementals
29! ALL-NEXT:'omp.private' Pipeline
30! O2-NEXT:   SimplifyHLFIRIntrinsics
31! ALL:       InlineElementals
32! O2-NEXT: Canonicalizer
33! O2-NEXT: CSE
34! O2-NEXT: (S) {{.*}} num-cse'd
35! O2-NEXT: (S) {{.*}} num-dce'd
36! O2-NEXT: Pipeline Collection : ['fir.global', 'func.func', 'omp.declare_reduction', 'omp.private']
37! O2-NEXT: 'fir.global' Pipeline
38! O2-NEXT:   SimplifyHLFIRIntrinsics
39! O2-NEXT:   OptimizedBufferization
40! O2-NEXT:   InlineHLFIRAssign
41! O2-NEXT: 'func.func' Pipeline
42! O2-NEXT:   SimplifyHLFIRIntrinsics
43! O2-NEXT:   OptimizedBufferization
44! O2-NEXT:   InlineHLFIRAssign
45! O2-NEXT: 'omp.declare_reduction' Pipeline
46! O2-NEXT:   SimplifyHLFIRIntrinsics
47! O2-NEXT:   OptimizedBufferization
48! O2-NEXT:   InlineHLFIRAssign
49! O2-NEXT: 'omp.private' Pipeline
50! O2-NEXT:   SimplifyHLFIRIntrinsics
51! O2-NEXT:   OptimizedBufferization
52! O2-NEXT:   InlineHLFIRAssign
53! ALL: LowerHLFIROrderedAssignments
54! ALL-NEXT: LowerHLFIRIntrinsics
55! ALL-NEXT: BufferizeHLFIR
56! O2-NEXT: Pipeline Collection : ['fir.global', 'func.func', 'omp.declare_reduction', 'omp.private']
57! O2-NEXT:   'fir.global' Pipeline
58! O2-NEXT:     InlineHLFIRAssign
59! O2-NEXT:   'func.func' Pipeline
60! O2-NEXT:     InlineHLFIRAssign
61! O2-NEXT:   'omp.declare_reduction' Pipeline
62! O2-NEXT:     InlineHLFIRAssign
63! O2-NEXT:   'omp.private' Pipeline
64! O2-NEXT:     InlineHLFIRAssign
65! ALL-NEXT: ConvertHLFIRtoFIR
66! ALL-NEXT: CSE
67! Ideally, we need an output with only the pass names, but
68! there is currently no way to get that, so in order to
69! guarantee that the passes are in the expected order
70! (i.e. use -NEXT) we have to check the statistics output as well.
71! ALL-NEXT:   (S) 0 num-cse'd - Number of operations CSE'd
72! ALL-NEXT:   (S) 0 num-dce'd - Number of operations DCE'd
73
74! ALL-NEXT: Pipeline Collection : ['fir.global', 'func.func', 'omp.declare_reduction', 'omp.private']
75! ALL-NEXT: 'fir.global' Pipeline
76! ALL-NEXT:   CharacterConversion
77! ALL-NEXT: 'func.func' Pipeline
78! ALL-NEXT:   ArrayValueCopy
79! ALL-NEXT:   CharacterConversion
80! ALL-NEXT: 'omp.declare_reduction' Pipeline
81! ALL-NEXT:   CharacterConversion
82! ALL-NEXT: 'omp.private' Pipeline
83! ALL-NEXT:   CharacterConversion
84
85! ALL-NEXT: Canonicalizer
86! ALL-NEXT: SimplifyRegionLite
87!  O2-NEXT: SimplifyIntrinsics
88!  O2-NEXT: AlgebraicSimplification
89! ALL-NEXT: CSE
90! ALL-NEXT:   (S) 0 num-cse'd - Number of operations CSE'd
91! ALL-NEXT:   (S) 0 num-dce'd - Number of operations DCE'd
92
93! ALL-NEXT: 'func.func' Pipeline
94! ALL-NEXT:   MemoryAllocationOpt
95
96! ALL-NEXT: Inliner
97! ALL-NEXT: SimplifyRegionLite
98! ALL-NEXT: CSE
99! ALL-NEXT:   (S) 0 num-cse'd - Number of operations CSE'd
100! ALL-NEXT:   (S) 0 num-dce'd - Number of operations DCE'd
101
102! ALL-NEXT: PolymorphicOpConversion
103! ALL-NEXT: AssumedRankOpConversion
104! O2-NEXT:  AddAliasTags
105
106! ALL-NEXT: Pipeline Collection : ['fir.global', 'func.func', 'omp.declare_reduction', 'omp.private']
107! ALL-NEXT:    'fir.global' Pipeline
108! ALL-NEXT:      StackReclaim
109! ALL-NEXT:      CFGConversion
110! ALL-NEXT:    'func.func' Pipeline
111! ALL-NEXT:      StackReclaim
112! ALL-NEXT:      CFGConversion
113! ALL-NEXT:   'omp.declare_reduction' Pipeline
114! ALL-NEXT:      StackReclaim
115! ALL-NEXT:      CFGConversion
116! ALL-NEXT:   'omp.private' Pipeline
117! ALL-NEXT:      StackReclaim
118! ALL-NEXT:      CFGConversion
119
120! ALL-NEXT: SCFToControlFlow
121! ALL-NEXT: Canonicalizer
122! ALL-NEXT: SimplifyRegionLite
123! ALL-NEXT: CSE
124! ALL-NEXT:   (S) 0 num-cse'd - Number of operations CSE'd
125! ALL-NEXT:   (S) 0 num-dce'd - Number of operations DCE'd
126! ALL-NEXT: BoxedProcedurePass
127
128! ALL-NEXT: Pipeline Collection : ['fir.global', 'func.func', 'gpu.module', 'omp.declare_reduction', 'omp.private']
129! ALL-NEXT:   'fir.global' Pipeline
130! ALL-NEXT:    AbstractResultOpt
131! ALL-NEXT:  'func.func' Pipeline
132! ALL-NEXT:    AbstractResultOpt
133! ALL-NEXT:  'gpu.module' Pipeline
134! ALL-NEXT:   Pipeline Collection : ['func.func', 'gpu.func']
135! ALL-NEXT:   'func.func' Pipeline
136! ALL-NEXT:   AbstractResultOpt
137! ALL-NEXT:   'gpu.func' Pipeline
138! ALL-NEXT:   AbstractResultOpt
139! ALL-NEXT:  'omp.declare_reduction' Pipeline
140! ALL-NEXT:    AbstractResultOpt
141! ALL-NEXT:  'omp.private' Pipeline
142! ALL-NEXT:    AbstractResultOpt
143
144! ALL-NEXT: CodeGenRewrite
145! ALL-NEXT:   (S) 0 num-dce'd - Number of operations eliminated
146! ALL-NEXT: ExternalNameConversion
147! ALL-NEXT: TargetRewrite
148! ALL-NEXT: CompilerGeneratedNamesConversion
149! ALL-NEXT:  'func.func' Pipeline
150! ALL-NEXT:   FunctionAttr
151! ALL-NEXT: FIRToLLVMLowering
152! ALL-NOT: LLVMIRLoweringPass
153