[all-commits] [llvm/llvm-project] bf176c: [InstrProfiling] Use llvm.compiler.used instead of...

Fangrui Song via All-commits all-commits at lists.llvm.org
Fri Feb 26 16:14:19 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bf176c49e842693e16c97c05d3d5fad33fc3d617
      https://github.com/llvm/llvm-project/commit/bf176c49e842693e16c97c05d3d5fad33fc3d617
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-02-26 (Fri, 26 Feb 2021)

  Changed paths:
    M llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
    M llvm/test/Instrumentation/InstrProfiling/profiling.ll

  Log Message:
  -----------
  [InstrProfiling] Use llvm.compiler.used instead of llvm.used for ELF

Many optimizers (e.g.  GlobalOpt/ConstantMerge) do not respect linker semantics
for comdat and may not discard the sections as a unit.

The interconnected `__llvm_prf_{cnts,data}` sections (in comdat for ELF)
are similar to D97432: `__profd_` is not directly referenced, so
`__profd_` may be discarded while `__profc_` is retained, breaking the
interconnection.  We currently conservatively add all such sections to
`llvm.used` and let the linker do GC for ELF.

In D97448, we will change GlobalObject's in the llvm.used list to use SHF_GNU_RETAIN,
causing the metadata sections to be unnecessarily retained (some `check-profile` tests check for GC).
Use `llvm.compiler.used` to retain the current GC behavior.

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




More information about the All-commits mailing list