[all-commits] [llvm/llvm-project] 54902e: [InstrProfiling] Use weak alias for bias variable

Petr Hosek via All-commits all-commits at lists.llvm.org
Mon Jul 19 12:24:13 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 54902e00d1280785042e2c7ec71b25a949ade92c
      https://github.com/llvm/llvm-project/commit/54902e00d1280785042e2c7ec71b25a949ade92c
  Author: Petr Hosek <phosek at google.com>
  Date:   2021-07-19 (Mon, 19 Jul 2021)

  Changed paths:
    M compiler-rt/include/profile/InstrProfData.inc
    M compiler-rt/lib/profile/CMakeLists.txt
    M compiler-rt/lib/profile/InstrProfiling.h
    R compiler-rt/lib/profile/InstrProfilingBiasVar.c
    M compiler-rt/lib/profile/InstrProfilingBuffer.c
    M compiler-rt/lib/profile/InstrProfilingFile.c
    M compiler-rt/lib/profile/InstrProfilingInternal.c
    M compiler-rt/lib/profile/InstrProfilingInternal.h
    M compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c
    M compiler-rt/lib/profile/InstrProfilingUtil.h
    M llvm/include/llvm/ProfileData/InstrProf.h
    M llvm/include/llvm/ProfileData/InstrProfData.inc
    M llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
    M llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll

  Log Message:
  -----------
  [InstrProfiling] Use weak alias for bias variable

We need the compiler generated variable to override the weak symbol of
the same name inside the profile runtime, but using LinkOnceODRLinkage
results in weak symbol being emitted in which case the symbol selected
by the linker is going to depend on the order of inputs which can be
fragile.

This change replaces the use of weak definition inside the runtime with
a weak alias. We place the compiler generated symbol inside a COMDAT
group so dead definition can be garbage collected by the linker.

We also disable the use of runtime counter relocation on Darwin since
Mach-O doesn't support weak external references, but Darwin already uses
a different continous mode that relies on overmapping so runtime counter
relocation isn't needed there.

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




More information about the All-commits mailing list