blob: eae35a040e5f83ee5e0ac2a06174f456096f518a [file] [log] [blame]
Dehao Chen874bc742017-06-27 17:45:40 +00001// 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
Dehao Chen1240bd32017-03-23 21:20:17 +00002// 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
Dehao Chen6d441bf2017-06-29 23:33:13 +00003// 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
Dehao Chen4a7e66a2017-07-07 20:53:17 +00004// 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
Dehao Chence39fdd2017-03-21 19:55:46 +00005// Checks if hot call is inlined by normal compile, but not inlined by
6// thinlto compile.
7
8int baz(int);
9int g;
10
11void foo(int n) {
12 for (int i = 0; i < n; i++)
13 g += baz(i);
14}
15
Rafael Espindola922f2aa2018-02-23 19:30:48 +000016// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @bar
17// THINLTO-LABEL: define {{(dso_local )?}}void @bar
Dehao Chen874bc742017-06-27 17:45:40 +000018// SAMPLEPGO-NOT: call{{.*}}foo
Dehao Chen1240bd32017-03-23 21:20:17 +000019// THINLTO: call{{.*}}foo
Dehao Chence39fdd2017-03-21 19:55:46 +000020void bar(int n) {
21 for (int i = 0; i < n; i++)
22 foo(i);
23}
Dehao Chen1240bd32017-03-23 21:20:17 +000024
25// Checks if loop unroll is invoked by normal compile, but not thinlto compile.
Rafael Espindola922f2aa2018-02-23 19:30:48 +000026// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @unroll
27// THINLTO-LABEL: define {{(dso_local )?}}void @unroll
Dehao Chen874bc742017-06-27 17:45:40 +000028// SAMPLEPGO: call{{.*}}baz
29// SAMPLEPGO: call{{.*}}baz
Dehao Chen1240bd32017-03-23 21:20:17 +000030// THINLTO: call{{.*}}baz
31// THINLTO-NOT: call{{.*}}baz
32void unroll() {
33 for (int i = 0; i < 2; i++)
34 baz(i);
35}
36
Dehao Chen874bc742017-06-27 17:45:40 +000037// Checks that icp is not invoked for ThinLTO, but invoked for normal samplepgo.
Rafael Espindola922f2aa2018-02-23 19:30:48 +000038// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @icp
39// THINLTO-LABEL: define {{(dso_local )?}}void @icp
Dehao Chen874bc742017-06-27 17:45:40 +000040// SAMPLEPGO: if.true.direct_targ
Dehao Chen6d441bf2017-06-29 23:33:13 +000041// FIXME: the following condition needs to be reversed once
42// LTOPreLinkDefaultPipeline is customized.
43// THINLTO-NOT: if.true.direct_targ
Dehao Chen1240bd32017-03-23 21:20:17 +000044void icp(void (*p)()) {
45 p();
46}