1 // RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
2 // RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
3 // RUN: %clang_cc1 -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
4 // RUN: %clang_cc1 -fdebug-pass-manager -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
5 
6 int baz(int);
7 int g;
8 
9 void foo(int n) {
10   for (int i = 0; i < n; i++)
11     g += baz(i);
12 }
13 
14 // Checks that loop unroll and icp are invoked by normal compile, but not thinlto compile.
15 
16 // SAMPLEPGO:               Running pass: PGOIndirectCallPromotion on [module]
17 // SAMPLEPGO:               Running pass: LoopUnrollPass on bar
18 
19 // SAMPLEPGO-OLDPM:         PGOIndirectCallPromotion
20 // SAMPLEPGO-OLDPM:         Unroll loops
21 // SAMPLEPGO-OLDPM:         Unroll loops
22 
23 // THINLTO-NOT:             Running pass: PGOIndirectCallPromotion on [module]
24 // THINLTO-NOT:             Running pass: LoopUnrollPass on bar
25 
26 // THINLTO-OLDPM-NOT:       PGOIndirectCallPromotion
27 // The first Unroll loop pass is the createSimpleLoopUnrollPass that unrolls and peels
28 // loops with small constant trip counts. The second one is skipped by ThinLTO.
29 // THINLTO-OLDPM:           Unroll loops
30 // THINLTO-OLDPM-NOT:       Unroll loops
31 
32 
33 // Checks if hot call is inlined by normal compile, but not inlined by
34 // thinlto compile.
35 // SAMPLEPGO-LABEL: define {{(dso_local )?}}void @bar
36 // THINLTO-LABEL: define {{(dso_local )?}}void @bar
37 // SAMPLEPGO-NOT: call{{.*}}foo
38 // THINLTO: call{{.*}}foo
39 void bar(int n) {
40   for (int i = 0; i < n; i++)
41     foo(i);
42 }