[PATCH] D103355: [InstrProfiling] Delete linkage/visibility toggling for Windows

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 28 23:43:26 PDT 2021


MaskRay created this revision.
Herald added a subscriber: hiraditya.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The linkage/visibility of `__profn_*` variables are derived
from the profiled functions.

  extern_weak => linkonce
  available_externally => linkonce_odr
  internal => private
  extern => private
  _ => unchanged

The linkage/visibility of `__profc_*`/`__profd_*` variables are derived from
`__profn_*` with linkage/visibility wrestling for Windows.

The changes can be folded to the following without changing semantics.

  if (TT.isOSBinFormatCOFF() && !NeedComdat) {
    Linkage = GlobalValue::InternalLinkage;
    Visibility = GlobalValue::DefaultVisibility;
  }

That said, I think we can just delete the code block.

An extern/internal function will now use private `__profc_*`/`__profd_*`
variables, instead of internal ones. This saves some symbol table entries.

A non-comdat {linkonce,weak}_odr function will now use hidden external
`__profc_*`/`__profd_*` variables instead of internal ones.  There is potential
object file size increase because such symbols need `/INCLUDE:` directives.
However such non-comdat functions are rare (note that non-comdat weak
definitions don't prevent duplicate definition error).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103355

Files:
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/linkage.ll
  llvm/test/Instrumentation/InstrProfiling/platform.ll
  llvm/test/Instrumentation/InstrProfiling/profiling.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103355.348617.patch
Type: text/x-patch
Size: 6550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210529/0f65a508/attachment.bin>


More information about the llvm-commits mailing list