Changeset View
Changeset View
Standalone View
Standalone View
clang/test/CodeGen/pgo-sample-thinlto-summary.c
// Tests to ensure that *LTO pre-link compiles don't perform optimizations | |||||
// that can lead to subpar SamplePGO matching in the LTO backends. | |||||
// 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 | // 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 | ||||
// 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 | // 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=LTO | ||||
// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto -o - 2>&1 | FileCheck %s -check-prefix=LTO | |||||
// 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 | // 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 | ||||
// 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 | // 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=LTO | ||||
// Checks if hot call is inlined by normal compile, but not inlined by | // RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto -o - 2>&1 | FileCheck %s -check-prefix=LTO | ||||
// thinlto compile. | |||||
int baz(int); | int baz(int); | ||||
int g; | int g; | ||||
void foo(int n) { | void foo(int n) { | ||||
for (int i = 0; i < n; i++) | for (int i = 0; i < n; i++) | ||||
g += baz(i); | g += baz(i); | ||||
} | } | ||||
// Checks if hot call is inlined by normal compile, but not inlined by | |||||
// (thin)lto pre-link compile. | |||||
// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @bar | // SAMPLEPGO-LABEL: define {{(dso_local )?}}void @bar | ||||
// THINLTO-LABEL: define {{(dso_local )?}}void @bar | // LTO-LABEL: define {{(dso_local )?}}void @bar | ||||
// SAMPLEPGO-NOT: call{{.*}}foo | // SAMPLEPGO-NOT: call{{.*}}foo | ||||
// THINLTO: call{{.*}}foo | // LTO: call{{.*}}foo | ||||
void bar(int n) { | void bar(int n) { | ||||
for (int i = 0; i < n; i++) | for (int i = 0; i < n; i++) | ||||
foo(i); | foo(i); | ||||
} | } | ||||
// Checks if loop unroll is invoked by normal compile, but not thinlto compile. | // Checks if loop unroll is invoked by normal compile, but not (thin)lto | ||||
// pre-link compile. | |||||
// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @unroll | // SAMPLEPGO-LABEL: define {{(dso_local )?}}void @unroll | ||||
// THINLTO-LABEL: define {{(dso_local )?}}void @unroll | // LTO-LABEL: define {{(dso_local )?}}void @unroll | ||||
// SAMPLEPGO: call{{.*}}baz | // SAMPLEPGO: call{{.*}}baz | ||||
// SAMPLEPGO: call{{.*}}baz | // SAMPLEPGO: call{{.*}}baz | ||||
// THINLTO: call{{.*}}baz | // LTO: call{{.*}}baz | ||||
// THINLTO-NOT: call{{.*}}baz | // LTO-NOT: call{{.*}}baz | ||||
void unroll() { | void unroll() { | ||||
for (int i = 0; i < 2; i++) | for (int i = 0; i < 2; i++) | ||||
baz(i); | baz(i); | ||||
} | } | ||||
// Checks that icp is not invoked for ThinLTO, but invoked for normal samplepgo. | // Checks that icp is not invoked for (Thin)LTO pre-link compile, but invoked | ||||
// for normal samplepgo. | |||||
// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @icp | // SAMPLEPGO-LABEL: define {{(dso_local )?}}void @icp | ||||
// THINLTO-LABEL: define {{(dso_local )?}}void @icp | // LTO-LABEL: define {{(dso_local )?}}void @icp | ||||
// SAMPLEPGO: if.true.direct_targ | // SAMPLEPGO: if.true.direct_targ | ||||
// FIXME: the following condition needs to be reversed once | // FIXME: the following condition needs to be reversed once | ||||
// LTOPreLinkDefaultPipeline is customized. | // LTOPreLinkDefaultPipeline is customized. | ||||
// THINLTO-NOT: if.true.direct_targ | // LTO-NOT: if.true.direct_targ | ||||
void icp(void (*p)()) { | void icp(void (*p)()) { | ||||
p(); | p(); | ||||
} | } |