brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 88c5069 Raw
61 lines · c
1// Tests for -fprofile-generate and -fprofile-use flag compatibility. These two2// flags behave similarly to their GCC counterparts:3//4// -fprofile-generate         Generates the profile file ./default.profraw5// -fprofile-generate=<dir>   Generates the profile file <dir>/default.profraw6// -fprofile-use              Uses the profile file ./default.profdata7// -fprofile-use=<dir>        Uses the profile file <dir>/default.profdata8// -fprofile-use=<dir>/file   Uses the profile file <dir>/file9 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 -flto11// RUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate | FileCheck -check-prefix=PROFILE-GEN %s12// PROFILE-GEN: @__profc_{{_?}}main = {{(private|internal)}} global [2 x i64] zeroinitializer, section13// PROFILE-GEN: @__profd_{{_?}}main =14 15// Check that -fprofile-generate=/path/to generates /path/to/default.profraw16// RxUN: %clang %s -c -S -o - -emit-llvm -fprofile-generate=/path/to | FileCheck -check-prefixes=PROFILE-GEN,PROFILE-GEN-EQ %s17// PROFILE-GEN-EQ: constant [{{.*}} x i8] c"/path/to{{/|\\\\}}{{.*}}\00"18 19// Check that -fprofile-use=some/path reads some/path/default.profdata20// This uses Clang FE format profile.21// RUN: rm -rf %t.dir22// RUN: mkdir -p %t.dir/some/path23// RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/default.profdata24// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE %s25 26// Check that -fprofile-use=some/path/file.prof reads some/path/file.prof27// This uses Clang FE format profile.28// RUN: rm -rf %t.dir29// RUN: mkdir -p %t.dir/some/path30// RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility.proftext -o %t.dir/some/path/file.prof31// RUN: %clang %s -o - -Xclang -disable-llvm-passes -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE %s32// PROFILE-USE: = !{!"branch_weights", i32 101, i32 2}33 34// Check that -fprofile-use=some/path reads some/path/default.profdata35// This uses LLVM IR format profile.36// RUN: rm -rf %t.dir37// RUN: mkdir -p %t.dir/some/path38// RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility_IR.proftext -o %t.dir/some/path/default.profdata39// RUN: %clang %s -o - -emit-llvm -S -fprofile-use=%t.dir/some/path | FileCheck -check-prefix=PROFILE-USE-IR %s40 41// Check that -fprofile-use=some/path/file.prof reads some/path/file.prof42// This uses LLVM IR format profile.43// RUN: rm -rf %t.dir44// RUN: mkdir -p %t.dir/some/path45// RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility_IR.proftext -o %t.dir/some/path/file.prof46// RUN: %clang %s -o - -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE-IR %s47//48// RUN: llvm-profdata merge %S/Inputs/gcc-flag-compatibility_IR_entry.proftext -o %t.dir/some/path/file.prof49// RUN: %clang %s -o - -emit-llvm -S -fprofile-use=%t.dir/some/path/file.prof | FileCheck -check-prefix=PROFILE-USE-IR %s50 51// PROFILE-USE-IR: = !{!"branch_weights", i32 100, i32 1}52 53int X = 0;54 55int main(void) {56  int i;57  for (i = 0; i < 100; i++)58    X += i;59  return 0;60}61