[InstrProfiling] Use ELF section groups for counters, data and values
authorPetr Hosek <phosek@google.com>
Sat, 13 Jul 2019 21:02:07 +0000 (14:02 -0700)
committerPetr Hosek <phosek@google.com>
Mon, 22 Feb 2021 22:00:02 +0000 (14:00 -0800)
commitc24b7a16b1001a8978335183d958fd0aa482c1d9
tree9a6c089e4d16cf5c959c7c2643210bbc943340f7
parent212d6a95abe67f038a6d9a26d2226f07c3132d0e
[InstrProfiling] Use ELF section groups for counters, data and values

__start_/__stop_ references retain C identifier name sections such as
__llvm_prf_*. Putting these into a section group disables this logic.

The ELF section group semantics ensures that group members are retained
or discarded as a unit. When a function symbol is discarded, this allows
allows linker to discard counters, data and values associated with that
function symbol as well.

Note that `noduplicates` COMDAT is lowered to zero-flag section group in
ELF. We only set this for functions that aren't already in a COMDAT and
for those that don't have available_externally linkage since we already
use regular COMDAT groups for those.

Differential Revision: https://reviews.llvm.org/D96757
compiler-rt/test/CMakeLists.txt
compiler-rt/test/profile/CMakeLists.txt
compiler-rt/test/profile/instrprof-gc-sections.c [new file with mode: 0644]
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
llvm/test/Instrumentation/InstrProfiling/icall.ll
llvm/test/Instrumentation/InstrProfiling/linkage.ll
llvm/test/Instrumentation/InstrProfiling/platform.ll
llvm/test/Transforms/PGOProfile/counter_promo.ll
llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll