[all-commits] [llvm/llvm-project] 330724: [InstrProfiling][ELF] Make __profd_ private if the...

Fangrui Song via All-commits all-commits at lists.llvm.org
Fri Jun 18 17:01:32 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3307240f057b856bfb01c1e42e260aa3f896c592
      https://github.com/llvm/llvm-project/commit/3307240f057b856bfb01c1e42e260aa3f896c592
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-06-18 (Fri, 18 Jun 2021)

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

  Log Message:
  -----------
  [InstrProfiling][ELF] Make __profd_ private if the function does not use value profiling

On ELF, the D1003372 optimization can apply to more cases. There are two
prerequisites for making `__profd_` private:

* `__profc_` keeps `__profd_` live under compiler/linker GC
* `__profd_` is not referenced by code

The first is satisfied because all counters/data are in a section group (either
`comdat any` or `comdat noduplicates`). The second requires that the function
does not use value profiling.

Regarding the second point: `__profd_` may be referenced by other text sections
due to inlining. There will be a linker error if a prevailing text section
references the non-prevailing local symbol.

With this change, a stage 2 (`-DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_BUILD_INSTRUMENTED=IR`)
clang is 4.2% smaller (1-169620032/177066968).
`stat -c %s **/*.o | awk '{s+=$1}END{print s}' is 2.5% smaller.

Reviewed By: davidxl, rnk

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




More information about the All-commits mailing list