diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-05-16 01:30:24 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-05-16 01:30:24 +0000 |
commit | fda7696ffbc58e4485f46a1de85512ee7fb65128 (patch) | |
tree | fe3278eb3a7ddf7c31cf82dad734a6a61aec1f80 /test | |
parent | 3a7550a78bd8f4c9e1eea7002e7ade6deb276d4c (diff) |
InstrProf: Fix shared object profiling
Change the API of the instrumented profiling library to work with shared
objects.
- Most things are now declared hidden, so that each executable gets
its own copy.
- Initialization hooks up a linked list of writers.
- The raw format with shared objects that are profiled consists of a
concatenated series of profiles. llvm-profdata knows how to deal
with that since r208938.
<rdar://problem/16918688>
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208940 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/profile/Inputs/instrprof-dynamic-a.cpp | 7 | ||||
-rw-r--r-- | test/profile/Inputs/instrprof-dynamic-b.cpp | 7 | ||||
-rw-r--r-- | test/profile/Inputs/instrprof-dynamic-header.h | 5 | ||||
-rw-r--r-- | test/profile/Inputs/instrprof-dynamic-main.cpp | 9 | ||||
-rw-r--r-- | test/profile/instrprof-dynamic-one-shared.test | 23 | ||||
-rw-r--r-- | test/profile/instrprof-dynamic-two-shared.test | 24 | ||||
-rw-r--r-- | test/profile/lit.cfg | 3 |
7 files changed, 78 insertions, 0 deletions
diff --git a/test/profile/Inputs/instrprof-dynamic-a.cpp b/test/profile/Inputs/instrprof-dynamic-a.cpp new file mode 100644 index 000000000..67de263c4 --- /dev/null +++ b/test/profile/Inputs/instrprof-dynamic-a.cpp @@ -0,0 +1,7 @@ +#include "instrprof-dynamic-header.h" +void a() { + if (true) { + bar<void>(); + bar<char>(); + } +} diff --git a/test/profile/Inputs/instrprof-dynamic-b.cpp b/test/profile/Inputs/instrprof-dynamic-b.cpp new file mode 100644 index 000000000..c8fb75ef5 --- /dev/null +++ b/test/profile/Inputs/instrprof-dynamic-b.cpp @@ -0,0 +1,7 @@ +#include "instrprof-dynamic-header.h" +void b() { + if (true) { + bar<void>(); + bar<int>(); + } +} diff --git a/test/profile/Inputs/instrprof-dynamic-header.h b/test/profile/Inputs/instrprof-dynamic-header.h new file mode 100644 index 000000000..1dc2e37ef --- /dev/null +++ b/test/profile/Inputs/instrprof-dynamic-header.h @@ -0,0 +1,5 @@ +template <class T> void bar() { + if (true) {} +} +void a(); +void b(); diff --git a/test/profile/Inputs/instrprof-dynamic-main.cpp b/test/profile/Inputs/instrprof-dynamic-main.cpp new file mode 100644 index 000000000..0dd602139 --- /dev/null +++ b/test/profile/Inputs/instrprof-dynamic-main.cpp @@ -0,0 +1,9 @@ +#include "instrprof-dynamic-header.h" +void foo(int K) { if (K) {} } +int main(int argc, char *argv[]) { + foo(5); + bar<void>(); + a(); + b(); + return 0; +} diff --git a/test/profile/instrprof-dynamic-one-shared.test b/test/profile/instrprof-dynamic-one-shared.test new file mode 100644 index 000000000..38be4fe8b --- /dev/null +++ b/test/profile/instrprof-dynamic-one-shared.test @@ -0,0 +1,23 @@ +RUN: mkdir -p %t.d +RUN: %clang_profgen -o %t.d/a.shared -fPIC -shared %S/Inputs/instrprof-dynamic-a.cpp +RUN: %clang_profgen -o %t-shared -fPIC -rpath %t.d %t.d/a.shared %S/Inputs/instrprof-dynamic-b.cpp %S/Inputs/instrprof-dynamic-main.cpp + +RUN: %clang_profgen -o %t-static %S/Inputs/instrprof-dynamic-a.cpp %S/Inputs/instrprof-dynamic-b.cpp %S/Inputs/instrprof-dynamic-main.cpp + +RUN: env LLVM_PROFILE_FILE=%t-static.profraw %run %t-static +RUN: env LLVM_PROFILE_FILE=%t-shared.profraw %run %t-shared + +RUN: llvm-profdata merge -o %t-static.profdata %t-static.profraw +RUN: llvm-profdata merge -o %t-shared.profdata %t-shared.profraw + +RUN: %clang_profuse=%t-static.profdata -o %t-a.static.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-a.cpp +RUN: %clang_profuse=%t-shared.profdata -o %t-a.shared.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-a.cpp +RUN: diff %t-a.static.ll %t-a.shared.ll + +RUN: %clang_profuse=%t-static.profdata -o %t-b.static.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-b.cpp +RUN: %clang_profuse=%t-shared.profdata -o %t-b.shared.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-b.cpp +RUN: diff %t-b.static.ll %t-b.shared.ll + +RUN: %clang_profuse=%t-static.profdata -o %t-main.static.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-main.cpp +RUN: %clang_profuse=%t-shared.profdata -o %t-main.shared.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-main.cpp +RUN: diff %t-main.static.ll %t-main.shared.ll diff --git a/test/profile/instrprof-dynamic-two-shared.test b/test/profile/instrprof-dynamic-two-shared.test new file mode 100644 index 000000000..830359dec --- /dev/null +++ b/test/profile/instrprof-dynamic-two-shared.test @@ -0,0 +1,24 @@ +RUN: mkdir -p %t.d +RUN: %clang_profgen -o %t.d/a.shared -fPIC -shared %S/Inputs/instrprof-dynamic-a.cpp +RUN: %clang_profgen -o %t.d/b.shared -fPIC -shared %S/Inputs/instrprof-dynamic-b.cpp +RUN: %clang_profgen -o %t-shared -fPIC -rpath %t.d %t.d/a.shared %t.d/b.shared %S/Inputs/instrprof-dynamic-main.cpp + +RUN: %clang_profgen -o %t-static %S/Inputs/instrprof-dynamic-a.cpp %S/Inputs/instrprof-dynamic-b.cpp %S/Inputs/instrprof-dynamic-main.cpp + +RUN: env LLVM_PROFILE_FILE=%t-static.profraw %run %t-static +RUN: env LLVM_PROFILE_FILE=%t-shared.profraw %run %t-shared + +RUN: llvm-profdata merge -o %t-static.profdata %t-static.profraw +RUN: llvm-profdata merge -o %t-shared.profdata %t-shared.profraw + +RUN: %clang_profuse=%t-static.profdata -o %t-a.static.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-a.cpp +RUN: %clang_profuse=%t-shared.profdata -o %t-a.shared.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-a.cpp +RUN: diff %t-a.static.ll %t-a.shared.ll + +RUN: %clang_profuse=%t-static.profdata -o %t-b.static.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-b.cpp +RUN: %clang_profuse=%t-shared.profdata -o %t-b.shared.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-b.cpp +RUN: diff %t-b.static.ll %t-b.shared.ll + +RUN: %clang_profuse=%t-static.profdata -o %t-main.static.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-main.cpp +RUN: %clang_profuse=%t-shared.profdata -o %t-main.shared.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-main.cpp +RUN: diff %t-main.static.ll %t-main.shared.ll diff --git a/test/profile/lit.cfg b/test/profile/lit.cfg index da09f1a61..e4d510c5f 100644 --- a/test/profile/lit.cfg +++ b/test/profile/lit.cfg @@ -27,6 +27,9 @@ if config.test_exec_root is None: # Test suffixes. config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test'] +# What to exclude. +config.excludes = ['Inputs'] + # Clang flags. clang_cflags = [config.target_cflags] |