| Diego Novillo | 578caf5 | 2015-07-09 17:23:53 +0000 | [diff] [blame] | 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 | |
| Diego Novillo | 578caf5 | 2015-07-09 17:23:53 +0000 | [diff] [blame] | 10 | // RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate | FileCheck -check-prefix=PROFILE-GEN %s |
| Xinliang David Li | 9081de2 | 2016-07-21 23:19:39 +0000 | [diff] [blame] | 11 | // PROFILE-GEN: __llvm_profile_filename |
| Diego Novillo | 578caf5 | 2015-07-09 17:23:53 +0000 | [diff] [blame] | 12 | |
| 13 | // Check that -fprofile-generate=/path/to generates /path/to/default.profraw |
| 14 | // RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to | FileCheck -check-prefix=PROFILE-GEN-EQ %s |
| Xinliang David Li | b7b335a | 2016-07-22 22:25:01 +0000 | [diff] [blame] | 15 | // PROFILE-GEN-EQ: constant [{{.*}} x i8] c"/path/to{{/|\\5C}}{{.*}}\00" |
| Diego Novillo | 578caf5 | 2015-07-09 17:23:53 +0000 | [diff] [blame] | 16 | |
| Diego Novillo | 578caf5 | 2015-07-09 17:23:53 +0000 | [diff] [blame] | 17 | // Check that -fprofile-use=some/path reads some/path/default.profdata |
| 18 | // RUN: rm -rf %t.dir |
| 19 | // RUN: mkdir -p %t.dir/some/path |
| 20 | // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/default.profdata |
| Chandler Carruth | 9d25111 | 2017-01-12 22:48:28 +0000 | [diff] [blame] | 21 | // RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE-2 %s |
| Diego Novillo | 578caf5 | 2015-07-09 17:23:53 +0000 | [diff] [blame] | 22 | // PROFILE-USE-2: = !{!"branch_weights", i32 101, i32 2} |
| 23 | |
| 24 | // Check that -fprofile-use=some/path/file.prof reads some/path/file.prof |
| 25 | // RUN: rm -rf %t.dir |
| 26 | // RUN: mkdir -p %t.dir/some/path |
| 27 | // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/file.prof |
| Chandler Carruth | 9d25111 | 2017-01-12 22:48:28 +0000 | [diff] [blame] | 28 | // RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE-3 %s |
| Diego Novillo | 578caf5 | 2015-07-09 17:23:53 +0000 | [diff] [blame] | 29 | // PROFILE-USE-3: = !{!"branch_weights", i32 101, i32 2} |
| 30 | |
| 31 | int X = 0; |
| 32 | |
| 33 | int main() { |
| 34 | int i; |
| 35 | for (i = 0; i < 100; i++) |
| 36 | X += i; |
| 37 | return 0; |
| 38 | } |