llvm-project/llvm/test/Instrumentation/InstrProfiling
Reid Kleckner 32837a0c93 [PGO] Use linkonce_odr linkage for __profd_ variables in comdat groups
This fixes relocations against __profd_ symbols in discarded sections,
which is PR41380.

In general, instrumentation happens very early, and optimization and
inlining happens afterwards. The counters for a function are calculated
early, and after inlining, counters for an inlined function may be
widely referenced by other functions.

For C++ inline functions of all kinds (linkonce_odr &
available_externally mainly), instr profiling wants to deduplicate these
__profc_ and __profd_ globals. Otherwise the binary would be quite
large.

I made __profd_ and __profc_ comdat in r355044, but I chose to make
__profd_ internal. At the time, I was only dealing with coverage, and in
that case, none of the instrumentation needs to reference __profd_.
However, if you use PGO, then instrumentation passes add calls to
__llvm_profile_instrument_range which reference __profd_ globals. The
solution is to make these globals externally visible by using
linkonce_odr linkage for data as was done for counters.

This is safe because PGO adds a CFG hash to the names of the data and
counter globals, so if different TUs have different globals, they will
get different data and counter arrays.

Reviewers: xur, hans

Differential Revision: https://reviews.llvm.org/D67579

llvm-svn: 372020
2019-09-16 18:49:09 +00:00
..
X86 [lit] Delete empty lines at the end of lit.local.cfg NFC 2019-06-17 09:51:07 +00:00
PR23499.ll [PGO] Use linkonce_odr linkage for __profd_ variables in comdat groups 2019-09-16 18:49:09 +00:00
always_inline.ll
atomic-updates.ll [InstrProf] Use atomic profile counter updates for TSan 2018-08-16 22:24:47 +00:00
comdat.ll [PGO] Use linkonce_odr linkage for __profd_ variables in comdat groups 2019-09-16 18:49:09 +00:00
early-exit.ll
icall.ll
linkage.ll [PGO] Use linkonce_odr linkage for __profd_ variables in comdat groups 2019-09-16 18:49:09 +00:00
no-counters.ll
noruntime.ll
platform.ll [profile] Solaris ld supports __start___llvm_prof_data etc. labels 2019-06-20 21:27:06 +00:00
profiling.ll