| 1 |
// Tests for -fprofile-generate and -fprofile-use flag compatibility. These two |
| 2 |
// flags behave similarly to their GCC counterparts: |
| 3 |
// |
| 4 |
// -fprofile-generate Generates the profile file ./default.profraw |
| 5 |
// -fprofile-generate=<dir> Generates the profile file <dir>/default.profraw |
| 6 |
// -fprofile-use Uses the profile file ./default.profdata |
| 7 |
// -fprofile-use=<dir> Uses the profile file <dir>/default.profdata |
| 8 |
// -fprofile-use=<dir>/file Uses the profile file <dir>/file |
| 9 |
|
| 10 |
// On AIX, -flto used to be required with -fprofile-generate, so test those |
| 11 |
// extra cases. |
| 12 |
|
| 13 |
// RUN: %clang %s -c -S -o - -emit-llvm -target powerpc64-unknown-aix -flto -fprofile-generate | FileCheck -check-prefix=PROFILE-GEN %s |
| 14 |
// PROFILE-GEN: @__profc_main = {{(private|internal)}} global [2 x i64] zeroinitializer, section |
| 15 |
// PROFILE-GEN: @__profd_main = |
| 16 |
|
| 17 |
// Check that -fprofile-generate=/path/to generates /path/to/default.profraw |
| 18 |
// RxUN: %clang %s -c -S -o - -emit-llvm -target powerpc64-unknown-aix -flto -fprofile-generate=/path/to | FileCheck -check-prefixes=PROFILE-GEN,PROFILE-GEN-EQ %s |
| 19 |
// PROFILE-GEN-EQ: constant [{{.*}} x i8] c"/path/to{{/|\\\\}}{{.*}}\00" |
| 20 |
|
| 21 |
// Check that -fprofile-use=some/path reads some/path/default.profdata |
| 22 |
// This uses Clang FE format profile. |
| 23 |
// RUN: rm -rf %t.dir |
| 24 |
// RUN: mkdir -p %t.dir/some/path |
| 25 |
// RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/default.profdata |
| 26 |
// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE %s |
| 27 |
|
| 28 |
// Check that -fprofile-use=some/path/file.prof reads some/path/file.prof |
| 29 |
// This uses Clang FE format profile. |
| 30 |
// RUN: rm -rf %t.dir |
| 31 |
// RUN: mkdir -p %t.dir/some/path |
| 32 |
// RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/file.prof |
| 33 |
// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE %s |
| 34 |
// PROFILE-USE: = !{!"branch_weights", i32 101, i32 2} |
| 35 |
|
| 36 |
// Check that -fprofile-use=some/path reads some/path/default.profdata |
| 37 |
// This uses LLVM IR format profile. |
| 38 |
// RUN: rm -rf %t.dir |
| 39 |
// RUN: mkdir -p %t.dir/some/path |
| 40 |
// RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility_IR.proftext -o %t.dir/some/path/default.profdata |
| 41 |
// RUN: %clang %s -o - -emit-llvm -S -fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE-IR %s |
| 42 |
|
| 43 |
// Check that -fprofile-use=some/path/file.prof reads some/path/file.prof |
| 44 |
// This uses LLVM IR format profile. |
| 45 |
// RUN: rm -rf %t.dir |
| 46 |
// RUN: mkdir -p %t.dir/some/path |
| 47 |
// RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility_IR.proftext -o %t.dir/some/path/file.prof |
| 48 |
// RUN: %clang %s -o - -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE-IR %s |
| 49 |
// |
| 50 |
// RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility_IR_entry.proftext -o %t.dir/some/path/file.prof |
| 51 |
// RUN: %clang %s -o - -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE-IR %s |
| 52 |
|
| 53 |
// PROFILE-USE-IR: = !{!"branch_weights", i32 100, i32 1} |
| 54 |
|
| 55 |
int X = 0; |
| 56 |
|
| 57 |
int main(void) { |
| 58 |
int i; |
| 59 |
for (i = 0; i < 100; i++) |
| 60 |
X += i; |
| 61 |
return 0; |
| 62 |
} |