1 // Tests for -fprofile-generate and -fprofile-use flag compatibility. These two
2 // flags behave similarly to their GCC counterparts:
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
10 // On AIX, -flto used to be required with -fprofile-generate, so test those
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 =
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"
21 // Check that -fprofile-use=some/path reads some/path/default.profdata
22 // This uses Clang FE format profile.
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
28 // Check that -fprofile-use=some/path/file.prof reads some/path/file.prof
29 // This uses Clang FE format profile.
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}
36 // Check that -fprofile-use=some/path reads some/path/default.profdata
37 // This uses LLVM IR format profile.
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
43 // Check that -fprofile-use=some/path/file.prof reads some/path/file.prof
44 // This uses LLVM IR format profile.
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
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
53 // PROFILE-USE-IR: = !{!"branch_weights", i32 100, i32 1}
59 for (i
= 0; i
< 100; i
++)