llvm-project/compiler-rt/lib/profile
Vedant Kumar ff3227e77d [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
2017-06-29 17:42:24 +00:00
..
CMakeLists.txt [profile] Move __llvm_profile_filename into a separate object 2017-06-29 17:42:24 +00:00
GCDAProfiling.c Define compatibility flag if not defined with -std=c++ 2016-07-25 23:12:53 +00:00
InstrProfData.inc [profile] Sync up InstrProfData.inc (NFC) 2017-04-15 00:10:33 +00:00
InstrProfiling.c [profile] Move __llvm_profile_filename into a separate object 2017-06-29 17:42:24 +00:00
InstrProfiling.h [Profile] Implement new API __llvm_profile_dump 2016-08-09 04:21:14 +00:00
InstrProfilingBuffer.c [PGO] Reduce IO in profile dumping with merging 2017-06-28 16:46:06 +00:00
InstrProfilingFile.c [PGO] Reduce IO in profile dumping with merging 2017-06-28 16:46:06 +00:00
InstrProfilingInternal.h [PGO] Reduce IO in profile dumping with merging 2017-06-28 16:46:06 +00:00
InstrProfilingMerge.c [profile] in-process merging support part-3 2016-06-08 23:43:56 +00:00
InstrProfilingMergeFile.c [PGO] internal API name cleanups (for better consistency) 2016-03-06 04:18:13 +00:00
InstrProfilingNameVar.c [profile] Move __llvm_profile_filename into a separate object 2017-06-29 17:42:24 +00:00
InstrProfilingPlatformDarwin.c [profile] initialize static pool properly 2016-05-22 16:36:03 +00:00
InstrProfilingPlatformLinux.c [profile] initialize static pool properly 2016-05-22 16:36:03 +00:00
InstrProfilingPlatformOther.c [profile] initialize static pool properly 2016-05-22 16:36:03 +00:00
InstrProfilingPort.h [profile] use GetComputerNameExW instead of gethostname on Windows 2016-11-29 15:24:00 +00:00
InstrProfilingRuntime.cc [Profile] cleanup: do not reference name directly of vars shared between rt and llvm 2016-07-22 04:08:16 +00:00
InstrProfilingUtil.c Resubmit r295469 [PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-write 2017-03-17 18:41:33 +00:00
InstrProfilingUtil.h Resubmit r295469 [PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-write 2017-03-17 18:41:33 +00:00
InstrProfilingValue.c [PGO] Value profile support for value ranges 2017-03-15 21:46:31 +00:00
InstrProfilingWriter.c [PGO] Reduce IO in profile dumping with merging 2017-06-28 16:46:06 +00:00
WindowsMMap.c profile: add missing include for Windows 2016-08-30 20:15:44 +00:00
WindowsMMap.h Fix most MSVC warnings in compiler-rt profiling library 2016-06-17 18:12:50 +00:00