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