[PATCH] D64045: [InstrProfiling] Put instrumentation into comdat group with function

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 1 15:58:56 PDT 2019


phosek created this revision.
phosek added reviewers: davidxl, vsk.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Currently, per-function instrumentation data don't use section groups
except for functions that already are in one and symbols with external
linkage. Consequentially, profiling instrumentation doesn't support
--gc-sections: if the function symbol is discarded, linker doesn't know
what other (instrumentation) data needs to be discarded as well. This
breaks any code that relies on --gc-sections semantics, and even for
other code that doesn't can lead to size increase.

This change moves per-function instrumentation data into its own section
group together with the function itself. This allows all instrumentation
to "travel together" with the symbol. If linker decides to discard the
symbol, it'll discard the entire group including all sections with the
instrumentation. The same strategy is already used by sancov.


Repository:
  rL LLVM

https://reviews.llvm.org/D64045

Files:
  llvm/include/llvm/ProfileData/InstrProf.h
  llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/PR23499.ll
  llvm/test/Instrumentation/InstrProfiling/comdat.ll
  llvm/test/Instrumentation/InstrProfiling/linkage.ll
  llvm/test/Instrumentation/InstrProfiling/platform.ll
  llvm/test/Transforms/PGOProfile/comdat_internal.ll
  llvm/test/Transforms/PGOProfile/comdat_rename.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64045.207426.patch
Type: text/x-patch
Size: 15681 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190701/680b06f4/attachment.bin>


More information about the llvm-commits mailing list