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. gcc-flag-compatibility-aix.c is used to do the testing on AIX with -flto 11 // RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate | FileCheck -check-prefix=PROFILE-GEN %s 12 // PROFILE-GEN: @__profc_{{_?}}main = {{(private|internal)}} global [2 x i64] zeroinitializer, section 13 // PROFILE-GEN: @__profd_{{_?}}main = 14 15 // Check that -fprofile-generate=/path/to generates /path/to/default.profraw 16 // RxUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to | FileCheck -check-prefixes=PROFILE-GEN,PROFILE-GEN-EQ %s 17 // PROFILE-GEN-EQ: constant [{{.*}} x i8] c"/path/to{{/|\\\\}}{{.*}}\00" 18 19 // Check that -fprofile-use=some/path reads some/path/default.profdata 20 // This uses Clang FE format profile. 21 // RUN: rm -rf %t.dir 22 // RUN: mkdir -p %t.dir/some/path 23 // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/default.profdata 24 // RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE %s 25 26 // Check that -fprofile-use=some/path/file.prof reads some/path/file.prof 27 // This uses Clang FE format profile. 28 // RUN: rm -rf %t.dir 29 // RUN: mkdir -p %t.dir/some/path 30 // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/file.prof 31 // 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 32 // PROFILE-USE: = !{!"branch_weights", i32 101, i32 2} 33 34 // Check that -fprofile-use=some/path reads some/path/default.profdata 35 // This uses LLVM IR format profile. 36 // RUN: rm -rf %t.dir 37 // RUN: mkdir -p %t.dir/some/path 38 // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility_IR.proftext -o %t.dir/some/path/default.profdata 39 // RUN: %clang %s -o - -emit-llvm -S -fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE-IR %s 40 41 // Check that -fprofile-use=some/path/file.prof reads some/path/file.prof 42 // This uses LLVM IR format profile. 43 // RUN: rm -rf %t.dir 44 // RUN: mkdir -p %t.dir/some/path 45 // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility_IR.proftext -o %t.dir/some/path/file.prof 46 // RUN: %clang %s -o - -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE-IR %s 47 // 48 // RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility_IR_entry.proftext -o %t.dir/some/path/file.prof 49 // RUN: %clang %s -o - -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE-IR %s 50 51 // PROFILE-USE-IR: = !{!"branch_weights", i32 100, i32 1} 52 53 int X = 0; 54 main(void)55int main(void) { 56 int i; 57 for (i = 0; i < 100; i++) 58 X += i; 59 return 0; 60 } 61