diff options
author | Vedant Kumar <vsk@apple.com> | 2019-10-18 23:33:40 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2019-10-18 23:33:40 +0000 |
commit | b19457ce72921f7eef9645b327337c933657e878 (patch) | |
tree | e7d1a6055e41c487783044206bf82a05d7df2504 /test | |
parent | 4aae16c11694f3d5aa65a5b7c05d2f6598f147ef (diff) | |
download | compiler-rt-b19457ce72921f7eef9645b327337c933657e878.tar.gz |
[profile] Do not cache __llvm_profile_get_filename result
When the %m filename pattern is used, the filename is unique to each
image, so the cached value is wrong.
It struck me that the full filename isn't something that's recomputed
often, so perhaps it doesn't need to be cached at all. David Li pointed
out we can go further and just hide lprofCurFilename. This may regress
workflows that depend on using the set-filename API to change filenames
across all loaded DSOs, but this is expected to be very rare.
rdar://55137071
Differential Revision: https://reviews.llvm.org/D69137
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@375301 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/profile/Inputs/instrprof-get-filename-dso.c | 5 | ||||
-rw-r--r-- | test/profile/Posix/instrprof-set-filename-shared.test | 8 | ||||
-rw-r--r-- | test/profile/instrprof-get-filename-merge-mode.c | 18 |
3 files changed, 23 insertions, 8 deletions
diff --git a/test/profile/Inputs/instrprof-get-filename-dso.c b/test/profile/Inputs/instrprof-get-filename-dso.c new file mode 100644 index 000000000..270943400 --- /dev/null +++ b/test/profile/Inputs/instrprof-get-filename-dso.c @@ -0,0 +1,5 @@ +const char *__llvm_profile_get_filename(void); + +const char *get_filename_from_DSO(void) { + return __llvm_profile_get_filename(); +} diff --git a/test/profile/Posix/instrprof-set-filename-shared.test b/test/profile/Posix/instrprof-set-filename-shared.test deleted file mode 100644 index 439c6c0dd..000000000 --- a/test/profile/Posix/instrprof-set-filename-shared.test +++ /dev/null @@ -1,8 +0,0 @@ -# Test that __llvm_profile_set_filename is honored by shared libary too. -RUN: mkdir -p %t.d -RUN: %clang_profgen=%t.shared.profraw -fPIC -shared -o %t.d/t.shared %S/../Inputs/instrprof-dlopen-func.c -RUN: %clang_profgen -DCALL_SHARED -o %t.m -O3 -rpath %t.d %t.d/t.shared %S/../instrprof-set-filename.c -RUN: %run %t.m %t.main.profraw -RUN: llvm-profdata show %t.main.profraw | FileCheck --check-prefix=SHARED %s - -# SHARED: Total functions: 2 diff --git a/test/profile/instrprof-get-filename-merge-mode.c b/test/profile/instrprof-get-filename-merge-mode.c new file mode 100644 index 000000000..c6e2fca22 --- /dev/null +++ b/test/profile/instrprof-get-filename-merge-mode.c @@ -0,0 +1,18 @@ +// Test __llvm_profile_get_filename when the on-line merging mode is enabled. +// +// RUN: %clang_pgogen -dynamiclib -o %t.dso %p/Inputs/instrprof-get-filename-dso.c +// RUN: %clang_pgogen -o %t %s %t.dso +// RUN: env LLVM_PROFILE_FILE="%t-%m.profraw" %run %t + +#include <string.h> + +const char *__llvm_profile_get_filename(void); +extern const char *get_filename_from_DSO(void); + +int main(int argc, const char *argv[]) { + const char *filename1 = __llvm_profile_get_filename(); + const char *filename2 = get_filename_from_DSO(); + + // Exit with code 1 if the two filenames are the same. + return strcmp(filename1, filename2) == 0; +} |