diff options
author | Vedant Kumar <vsk@apple.com> | 2017-06-29 17:42:24 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2017-06-29 17:42:24 +0000 |
commit | ff3227e77d559a2e44debe959910fbcc9f7806d6 (patch) | |
tree | 4e013ac5318c2fb3ef31512011b0602de82d3119 /compiler-rt/lib/profile/InstrProfilingNameVar.c | |
parent | 24340252a4f58b4d3fd29b73caf123c43dae792a (diff) | |
download | bcm5719-llvm-ff3227e77d559a2e44debe959910fbcc9f7806d6.tar.gz bcm5719-llvm-ff3227e77d559a2e44debe959910fbcc9f7806d6.zip |
[profile] Move __llvm_profile_filename into a separate object
Users can specify the path a raw profile is written to by passing
-fprofile-instr-generate=<path>, but this functionality broke on Darwin
after __llvm_profile_filename was made weak [1], resulting in profiles
being written to "default.profraw" even when <path> is specified.
The situation is that instrumented programs provide a weak definition of
__llvm_profile_filename, which conflicts with a weak redefinition
provided by the profiling runtime.
The linker appears to pick the 'winning' definition arbitrarily: on
Darwin, it usually prefers the larger definition, which is probably why
the instrprof-override-filename.c test has been passing.
The fix is to move the runtime's definition into a separate object file
within the archive. This means that the linker won't "see" the runtime's
definition unless the user program has not provided one. I couldn't
think of a great way to test this other than to mimic the Darwin
failure: use -fprofile-instr-generate=<some-small-path>.
Testing: check-{clang,profile}, modified instrprof-override-filename.c.
[1] [Profile] deprecate __llvm_profile_override_default_filename
https://reviews.llvm.org/D22613
https://reviews.llvm.org/D22614
Differential Revision: https://reviews.llvm.org/D34797
llvm-svn: 306710
Diffstat (limited to 'compiler-rt/lib/profile/InstrProfilingNameVar.c')
-rw-r--r-- | compiler-rt/lib/profile/InstrProfilingNameVar.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler-rt/lib/profile/InstrProfilingNameVar.c b/compiler-rt/lib/profile/InstrProfilingNameVar.c new file mode 100644 index 00000000000..a0c448c679b --- /dev/null +++ b/compiler-rt/lib/profile/InstrProfilingNameVar.c @@ -0,0 +1,18 @@ +//===- InstrProfilingNameVar.c - profile name variable setup --------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "InstrProfiling.h" + +/* char __llvm_profile_filename[1] + * + * The runtime should only provide its own definition of this symbol when the + * user has not specified one. Set this up by moving the runtime's copy of this + * symbol to an object file within the archive. + */ +COMPILER_RT_WEAK char INSTR_PROF_PROFILE_NAME_VAR[1] = {0}; |