1; Test the particular pass pipelines have the expected structure. This is
2; particularly important in order to check that the implicit scheduling of the
3; legacy pass manager doesn't introduce unexpected structural changes in the
4; pass pipeline.
5;
6; RUN: opt -enable-new-pm=0 -disable-output -disable-verify -debug-pass=Structure \
7; RUN:     -O2 %s 2>&1 \
8; RUN:     | FileCheck %s --check-prefix=CHECK-O2
9; RUN: llvm-profdata merge %S/Inputs/pass-pipelines.proftext -o %t.profdata
10; RUN: opt -enable-new-pm=0 -disable-output -disable-verify -debug-pass=Structure \
11; RUN:     -pgo-kind=pgo-instr-use-pipeline -profile-file='%t.profdata' \
12; RUN:     -O2 %s 2>&1 \
13; RUN:     | FileCheck %s --check-prefix=CHECK-O2 --check-prefix=PGOUSE
14; RUN: opt -enable-new-pm=0 -disable-output -disable-verify -debug-pass=Structure \
15; RUN:     -pgo-kind=pgo-instr-use-pipeline -profile-file='%t.profdata' \
16; RUN:     -hot-cold-split \
17; RUN:     -O2 %s 2>&1 \
18; RUN:     | FileCheck %s --check-prefix=CHECK-O2 --check-prefix=PGOUSE --check-prefix=SPLIT
19;
20; In the first pipeline there should just be a function pass manager, no other
21; pass managers.
22; CHECK-O2: Pass Arguments:
23; CHECK-O2-NOT: Manager
24; CHECK-O2: FunctionPass Manager
25; CHECK-O2-NOT: Manager
26;
27; CHECK-O2: Pass Arguments:
28; CHECK-O2: ModulePass Manager
29; CHECK-O2-NOT: Manager
30; First function pass pipeline just does early opts.
31; CHECK-O2-COUNT-3: FunctionPass Manager
32; CHECK-O2-NOT: Manager
33; FIXME: It's a bit odd to do dead arg elim in the middle of early opts...
34; CHECK-O2: Dead Argument Elimination
35; CHECK-O2-NEXT: FunctionPass Manager
36; CHECK-O2-NOT: Manager
37; Very carefully assert the CGSCC pass pipeline as it is fragile and unusually
38; susceptible to phase ordering issues.
39; CHECK-O2: CallGraph Construction
40; PGOUSE: Call Graph SCC Pass Manager
41; PGOUSE:      Function Integration/Inlining
42; PGOUSE: PGOInstrumentationUsePass
43; PGOUSE: PGOIndirectCallPromotion
44; PGOUSE: CallGraph Construction
45; CHECK-O2-NEXT: Globals Alias Analysis
46; CHECK-O2-NEXT: Call Graph SCC Pass Manager
47; CHECK-O2-NEXT: Remove unused exception handling info
48; CHECK-O2-NEXT: Function Integration/Inlining
49; CHECK-O2-NEXT: OpenMP specific optimizations
50; CHECK-O2-NEXT: Deduce function attributes
51; Next up is the main function pass pipeline. It shouldn't be split up and
52; should contain the main loop pass pipeline as well.
53; CHECK-O2-NEXT: FunctionPass Manager
54; CHECK-O2-NOT: Manager
55; CHECK-O2: Loop Pass Manager
56; CHECK-O2: Loop Pass Manager
57; CHECK-O2-NOT: Manager
58; FIXME: We shouldn't be pulling out to simplify-cfg and instcombine and
59; causing new loop pass managers.
60; CHECK-O2: Simplify the CFG
61; CHECK-O2-NOT: Manager
62; CHECK-O2: Combine redundant instructions
63; CHECK-O2-NOT: Manager
64; CHECK-O2: Loop Pass Manager
65; CHECK-O2-NOT: Manager
66; FIXME: It isn't clear that we need yet another loop pass pipeline
67; and run of LICM here.
68; CHECK-O2-NOT: Manager
69; CHECK-O2: Loop Pass Manager
70; CHECK-O2-NEXT: Loop Invariant Code Motion
71; CHECK-O2-NOT: Manager
72; Next we break out of the main Function passes inside the CGSCC pipeline with
73; a barrier pass.
74; CHECK-O2: A No-Op Barrier Pass
75; CHECK-O2-NEXT: Eliminate Available Externally
76; Inferring function attribute should be right after the CGSCC pipeline, before
77; any other optimizations/analyses.
78; CHECK-O2-NEXT: CallGraph
79; CHECK-O2-NEXT: Deduce function attributes in RPO
80; CHECK-O2-NOT: Manager
81; Reduce the size of the IR ASAP after the inliner.
82; CHECK-O2-NEXT: Global Variable Optimizer
83; CHECK-O2: Dead Global Elimination
84; Next is the late function pass pipeline.
85; CHECK-O2: FunctionPass Manager
86; CHECK-O2-NOT: Manager
87; We rotate loops prior to vectorization.
88; CHECK-O2: Loop Pass Manager
89; CHECK-O2-NEXT: Rotate Loops
90; CHECK-O2-NOT: Manager
91; CHECK-O2: Loop Vectorization
92; CHECK-O2-NOT: Manager
93; CHECK-O2: SLP Vectorizer
94; CHECK-O2-NOT: Manager
95; After vectorization we do partial unrolling.
96; CHECK-O2: Loop Pass Manager
97; CHECK-O2-NEXT: Unroll loops
98; CHECK-O2-NOT: Manager
99; After vectorization and unrolling we try to do any cleanup of inserted code,
100; including a run of LICM. This shouldn't run in the same loop pass manager as
101; the runtime unrolling though.
102; CHECK-O2: Loop Pass Manager
103; CHECK-O2-NEXT: Loop Invariant Code Motion
104; SPLIT: Hot Cold Splitting
105; CHECK-O2: FunctionPass Manager
106; CHECK-O2: Loop Pass Manager
107; CHECK-O2-NEXT: Loop Sink
108; CHECK-O2: Simplify the CFG
109; CHECK-O2-NOT: Manager
110;
111; FIXME: There really shouldn't be another pass manager, especially one that
112; just builds the domtree. It doesn't even run the verifier.
113; CHECK-O2: Pass Arguments:
114; CHECK-O2: FunctionPass Manager
115; CHECK-O2-NEXT: Dominator Tree Construction
116
117define void @foo() {
118  ret void
119}
120