]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/pgo-sample-thinlto-summary.c
Vendor import of clang trunk r338150:
[FreeBSD/FreeBSD.git] / test / CodeGen / pgo-sample-thinlto-summary.c
1 // RUN: %clang_cc1 -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 -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 // RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -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 -O2 -fexperimental-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
5 // Checks if hot call is inlined by normal compile, but not inlined by
6 // thinlto compile.
7
8 int baz(int);
9 int g;
10
11 void foo(int n) {
12   for (int i = 0; i < n; i++)
13     g += baz(i);
14 }
15
16 // SAMPLEPGO-LABEL: define {{(dso_local )?}}void @bar
17 // THINLTO-LABEL: define {{(dso_local )?}}void @bar
18 // SAMPLEPGO-NOT: call{{.*}}foo
19 // THINLTO: call{{.*}}foo
20 void bar(int n) {
21   for (int i = 0; i < n; i++)
22     foo(i);
23 }
24
25 // Checks if loop unroll is invoked by normal compile, but not thinlto compile.
26 // SAMPLEPGO-LABEL: define {{(dso_local )?}}void @unroll
27 // THINLTO-LABEL: define {{(dso_local )?}}void @unroll
28 // SAMPLEPGO: call{{.*}}baz
29 // SAMPLEPGO: call{{.*}}baz
30 // THINLTO: call{{.*}}baz
31 // THINLTO-NOT: call{{.*}}baz
32 void unroll() {
33   for (int i = 0; i < 2; i++)
34     baz(i);
35 }
36
37 // Checks that icp is not invoked for ThinLTO, but invoked for normal samplepgo.
38 // SAMPLEPGO-LABEL: define {{(dso_local )?}}void @icp
39 // THINLTO-LABEL: define {{(dso_local )?}}void @icp
40 // SAMPLEPGO: if.true.direct_targ
41 // FIXME: the following condition needs to be reversed once
42 //        LTOPreLinkDefaultPipeline is customized.
43 // THINLTO-NOT: if.true.direct_targ
44 void icp(void (*p)()) {
45   p();
46 }