[PATCH] D25707: [profile] Mark lprofCurFilename as COMPILER_RT_WEAK

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 15:54:34 PDT 2016

vsk created this revision.
vsk added a reviewer: davidxl.
vsk added a subscriber: llvm-commits.

This makes __llvm_profile_set_filename() work across dylib boundaries on

This functionality was originally meant to work on all platforms, but
was moved to a Linux-only directory with r272404. The root cause of the
test failure on Darwin was that lprofCurFilename was not marked weak.
Each dylib maintained its own copy of the variable due to the two-level

Tested with check-profile (on Darwin). I don't expect this to regress
other platforms.



Index: test/profile/instrprof-set-filename-shared.test
--- test/profile/instrprof-set-filename-shared.test
+++ test/profile/instrprof-set-filename-shared.test
@@ -1,7 +1,7 @@
 # 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: %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
Index: lib/profile/InstrProfilingFile.c
--- lib/profile/InstrProfilingFile.c
+++ lib/profile/InstrProfilingFile.c
@@ -82,7 +82,8 @@
   ProfileNameSpecifier PNS;
 } lprofFilename;
-lprofFilename lprofCurFilename = {0, 0, 0, {0}, {0}, 0, 0, 0, PNS_unknown};
+COMPILER_RT_WEAK lprofFilename lprofCurFilename = {0, 0, 0, {0}, {0},
+                                                   0, 0, 0, PNS_unknown};
 int getpid(void);
 static int getCurFilenameLength();

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25707.74928.patch
Type: text/x-patch
Size: 1395 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161017/b081ef84/attachment.bin>

More information about the llvm-commits mailing list