diff options
Diffstat (limited to 'test/profile')
-rw-r--r-- | test/profile/Inputs/gcc-flag-compatibility.c | 8 | ||||
-rw-r--r-- | test/profile/Inputs/instrprof-dynamic-a.cpp | 4 | ||||
-rw-r--r-- | test/profile/Inputs/instrprof-dynamic-b.cpp | 4 | ||||
-rw-r--r-- | test/profile/Inputs/instrprof-dynamic-header.h | 6 | ||||
-rw-r--r-- | test/profile/Inputs/instrprof-dynamic-main.cpp | 2 | ||||
-rw-r--r-- | test/profile/gcc-flag-compatibility.test | 17 | ||||
-rw-r--r-- | test/profile/instrprof-override-filename-then-reset-default.c | 19 | ||||
-rw-r--r-- | test/profile/instrprof-override-filename-with-env.c | 14 | ||||
-rw-r--r-- | test/profile/instrprof-override-filename.c | 14 | ||||
-rw-r--r-- | test/profile/instrprof-set-filename-then-reset-default.c | 18 | ||||
-rw-r--r-- | test/profile/lit.cfg | 2 |
11 files changed, 101 insertions, 7 deletions
diff --git a/test/profile/Inputs/gcc-flag-compatibility.c b/test/profile/Inputs/gcc-flag-compatibility.c new file mode 100644 index 000000000000..1c07bb1d0f30 --- /dev/null +++ b/test/profile/Inputs/gcc-flag-compatibility.c @@ -0,0 +1,8 @@ +int X = 0; + +int main() { + int i; + for (i = 0; i < 100; i++) + X += i; + return 0; +} diff --git a/test/profile/Inputs/instrprof-dynamic-a.cpp b/test/profile/Inputs/instrprof-dynamic-a.cpp index 67de263c4d88..2ec484a5b381 100644 --- a/test/profile/Inputs/instrprof-dynamic-a.cpp +++ b/test/profile/Inputs/instrprof-dynamic-a.cpp @@ -1,7 +1,7 @@ #include "instrprof-dynamic-header.h" void a() { if (true) { - bar<void>(); - bar<char>(); + bar<void>(1); + bar<char>(1); } } diff --git a/test/profile/Inputs/instrprof-dynamic-b.cpp b/test/profile/Inputs/instrprof-dynamic-b.cpp index c8fb75ef52ed..5c2d9bae8dba 100644 --- a/test/profile/Inputs/instrprof-dynamic-b.cpp +++ b/test/profile/Inputs/instrprof-dynamic-b.cpp @@ -1,7 +1,7 @@ #include "instrprof-dynamic-header.h" void b() { if (true) { - bar<void>(); - bar<int>(); + bar<void>(1); + bar<int>(1); } } diff --git a/test/profile/Inputs/instrprof-dynamic-header.h b/test/profile/Inputs/instrprof-dynamic-header.h index 1dc2e37ef82c..7a57b13c67f9 100644 --- a/test/profile/Inputs/instrprof-dynamic-header.h +++ b/test/profile/Inputs/instrprof-dynamic-header.h @@ -1,5 +1,7 @@ -template <class T> void bar() { - if (true) {} +template <class T> void bar(int X) { + if (X) { + X *= 4; + } } void a(); void b(); diff --git a/test/profile/Inputs/instrprof-dynamic-main.cpp b/test/profile/Inputs/instrprof-dynamic-main.cpp index 0dd60213926e..2cf37c8b6d5e 100644 --- a/test/profile/Inputs/instrprof-dynamic-main.cpp +++ b/test/profile/Inputs/instrprof-dynamic-main.cpp @@ -2,7 +2,7 @@ void foo(int K) { if (K) {} } int main(int argc, char *argv[]) { foo(5); - bar<void>(); + bar<void>(1); a(); b(); return 0; diff --git a/test/profile/gcc-flag-compatibility.test b/test/profile/gcc-flag-compatibility.test new file mode 100644 index 000000000000..8e8b55dafe23 --- /dev/null +++ b/test/profile/gcc-flag-compatibility.test @@ -0,0 +1,17 @@ +RUN: mkdir -p %t.d +RUN: %clang_profgen_gcc=%t.d/d1/d2 -o %t.d/code %S/Inputs/gcc-flag-compatibility.c + +# Test that the instrumented code writes to %t.d/d1/d2/default.profraw +RUN: %run %t.d/code +RUN: llvm-profdata merge -o %t.profdata %t.d/d1/d2/default.profraw + +# Test that we can override the directory and file name with LLVM_PROFILE_FILE. +RUN: env LLVM_PROFILE_FILE=%t.d/x1/prof.raw %run %t.d/code +RUN: llvm-profdata merge -o %t.profdata %t.d/x1/prof.raw + +# Test that we can specify a directory with -fprofile-use. +RUN: llvm-profdata merge -o %t.d/default.profdata %t.d/x1/prof.raw +RUN: %clang_profuse_gcc=%t.d -o %t.d/code %S/Inputs/gcc-flag-compatibility.c + +# Test that we can specify a file with -fprofile-use. +RUN: %clang_profuse_gcc=%t.profdata -o %t.d/code %S/Inputs/gcc-flag-compatibility.c diff --git a/test/profile/instrprof-override-filename-then-reset-default.c b/test/profile/instrprof-override-filename-then-reset-default.c new file mode 100644 index 000000000000..137a3b2f2291 --- /dev/null +++ b/test/profile/instrprof-override-filename-then-reset-default.c @@ -0,0 +1,19 @@ +// RUN: rm -rf %t.d +// RUN: mkdir -p %t.d +// RUN: cd %t.d +// RUN: %clang_profgen -O3 %s -o %t.out +// RUN: %run %t.out %t.d/bad.profraw +// RUN: llvm-profdata merge -o %t.d/default.profdata %t.d/default.profraw +// RUN: %clang_profuse=%t.d/default.profdata -o - -S -emit-llvm %s | FileCheck %s + + +void __llvm_profile_override_default_filename(const char *); +int main(int argc, const char *argv[]) { + // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]] + if (argc < 2) + return 1; + __llvm_profile_override_default_filename(argv[1]); + __llvm_profile_override_default_filename(0); + return 0; +} +// CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2} diff --git a/test/profile/instrprof-override-filename-with-env.c b/test/profile/instrprof-override-filename-with-env.c new file mode 100644 index 000000000000..cce83891663a --- /dev/null +++ b/test/profile/instrprof-override-filename-with-env.c @@ -0,0 +1,14 @@ +// RUN: %clang_profgen -o %t -O3 %s +// RUN: env LLVM_PROFILE_FILE=%t.good.profraw %run %t %t.bad.profraw +// RUN: llvm-profdata merge -o %t.profdata %t.good.profraw +// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s + +void __llvm_profile_override_default_filename(const char *); +int main(int argc, const char *argv[]) { + // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]] + if (argc < 2) + return 1; + __llvm_profile_override_default_filename(argv[1]); + return 0; +} +// CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2} diff --git a/test/profile/instrprof-override-filename.c b/test/profile/instrprof-override-filename.c new file mode 100644 index 000000000000..59dea29e3b88 --- /dev/null +++ b/test/profile/instrprof-override-filename.c @@ -0,0 +1,14 @@ +// RUN: %clang_profgen -o %t -O3 %s +// RUN: %run %t %t.profraw +// RUN: llvm-profdata merge -o %t.profdata %t.profraw +// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s + +void __llvm_profile_override_default_filename(const char *); +int main(int argc, const char *argv[]) { + // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]] + if (argc < 2) + return 1; + __llvm_profile_override_default_filename(argv[1]); + return 0; +} +// CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2} diff --git a/test/profile/instrprof-set-filename-then-reset-default.c b/test/profile/instrprof-set-filename-then-reset-default.c new file mode 100644 index 000000000000..6c07994f08c6 --- /dev/null +++ b/test/profile/instrprof-set-filename-then-reset-default.c @@ -0,0 +1,18 @@ +// RUN: rm -rf %t.d +// RUN: mkdir -p %t.d +// RUN: cd %t.d +// RUN: %clang_profgen -O3 %s -o %t.out +// RUN: %run %t.out %t.d/bad.profraw +// RUN: llvm-profdata merge -o %t.d/default.profdata %t.d/default.profraw +// RUN: %clang_profuse=%t.d/default.profdata -o - -S -emit-llvm %s | FileCheck %s + +void __llvm_profile_set_filename(const char *); +int main(int argc, const char *argv[]) { + // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]] + if (argc < 2) + return 1; + __llvm_profile_set_filename(argv[1]); + __llvm_profile_set_filename(0); + return 0; +} +// CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2} diff --git a/test/profile/lit.cfg b/test/profile/lit.cfg index e4910abbe7a4..b1b44a1a0665 100644 --- a/test/profile/lit.cfg +++ b/test/profile/lit.cfg @@ -45,6 +45,8 @@ def build_invocation(compile_flags): config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) ) config.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") ) config.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") ) +config.substitutions.append( ("%clang_profgen_gcc=", build_invocation(clang_cflags) + " -fprofile-generate=") ) +config.substitutions.append( ("%clang_profuse_gcc=", build_invocation(clang_cflags) + " -fprofile-use=") ) if config.host_os not in ['Darwin', 'FreeBSD', 'Linux']: config.unsupported = True |