]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGen/pgo-sample-thinlto-summary.c
Vendor import of clang trunk r300422:
[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=O2
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 // Checks if hot call is inlined by normal compile, but not inlined by
4 // thinlto compile.
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 // O2-LABEL: define void @bar
15 // THINLTO-LABEL: define void @bar
16 // O2-NOT: call{{.*}}foo
17 // THINLTO: call{{.*}}foo
18 void bar(int n) {
19   for (int i = 0; i < n; i++)
20     foo(i);
21 }
22
23 // Checks if loop unroll is invoked by normal compile, but not thinlto compile.
24 // O2-LABEL: define void @unroll
25 // THINLTO-LABEL: define void @unroll
26 // O2: call{{.*}}baz
27 // O2: call{{.*}}baz
28 // THINLTO: call{{.*}}baz
29 // THINLTO-NOT: call{{.*}}baz
30 void unroll() {
31   for (int i = 0; i < 2; i++)
32     baz(i);
33 }
34
35 // Checks if icp is invoked by normal compile, but not thinlto compile.
36 // O2-LABEL: define void @icp
37 // THINLTO-LABEL: define void @icp
38 // O2: if.true.direct_targ
39 // ThinLTO-NOT: if.true.direct_targ
40 void icp(void (*p)()) {
41   p();
42 }