[all-commits] [llvm/llvm-project] 87fd09: [InstrProfiling] Generate runtime hook for ELF pla...

Petr Hosek via All-commits all-commits at lists.llvm.org
Thu Mar 11 12:29:27 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 87fd09b25f8892e07b7ba11525baa9c3ec3e5d3f
      https://github.com/llvm/llvm-project/commit/87fd09b25f8892e07b7ba11525baa9c3ec3e5d3f
  Author: Petr Hosek <phosek at google.com>
  Date:   2021-03-11 (Thu, 11 Mar 2021)

  Changed paths:
    M clang/docs/UsersManual.rst
    M clang/lib/Driver/ToolChains/Fuchsia.cpp
    M clang/lib/Driver/ToolChains/Fuchsia.h
    M clang/lib/Driver/ToolChains/Linux.cpp
    M clang/lib/Driver/ToolChains/Linux.h
    M clang/test/Driver/coverage-ld.c
    M clang/test/Driver/fuchsia.c
    M llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
    M llvm/test/Instrumentation/InstrProfiling/linkage.ll
    M llvm/test/Instrumentation/InstrProfiling/profiling.ll

  Log Message:
  -----------
  [InstrProfiling] Generate runtime hook for ELF platforms

When using -fprofile-list to selectively apply instrumentation only
to certain files or functions, we may end up with a binary that doesn't
have any counters in the case where no files were selected. However,
because on Linux and Fuchsia, we pass -u__llvm_profile_runtime, the
runtime would still be pulled in and incur some non-trivial overhead,
especially in the case when the continuous or runtime counter relocation
mode is being used. A better way would be to pull in the profile runtime
only when needed by declaring the __llvm_profile_runtime symbol in the
translation unit only when needed.

This approach was already used prior to 9a041a75221ca, but we changed it
to always generate the __llvm_profile_runtime due to a TAPI limitation.
Since TAPI is only used on Mach-O platforms, we could use the early
emission of __llvm_profile_runtime there, and on other platforms we
could change back to the earlier approach where the symbol is generated
later only when needed. We can stop passing -u__llvm_profile_runtime to
the linker on Linux and Fuchsia since the generated undefined symbol in
each translation unit that needed it serves the same purpose.

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




More information about the All-commits mailing list