]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Profile/gcc-flag-compatibility.c
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / Profile / gcc-flag-compatibility.c
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 // RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate | FileCheck -check-prefix=PROFILE-GEN %s
11 // PROFILE-GEN: __llvm_profile_filename
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
15 // PROFILE-GEN-EQ: constant [{{.*}} x i8] c"/path/to{{/|\\5C}}{{.*}}\00"
16
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
21 // RUN: %clang %s -o - -mllvm -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE-2 %s
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
28 // RUN: %clang %s -o - -mllvm -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE-3 %s
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 }