[PATCH] D85782: [X86][ELF] Prefer lowering MC_GlobalAddress operands to .Lfoo$local only for STV_DEFAULT globals

ben via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 14:10:57 PDT 2020


bd1976llvm created this revision.
bd1976llvm added a reviewer: MaskRay.
Herald added subscribers: llvm-commits, dexonsmith, hiraditya.
Herald added a project: LLVM.
bd1976llvm requested review of this revision.

This patch restricts the behaviour of referencing via .Lfoo$local local aliases, introduced in https://reviews.llvm.org/D73230, to STV_DEFAULT globals only.

GNU now  recommends -fvisiblity=hidden (https://gcc.gnu.org/wiki/Visibility) so my understanding is that there will be very few STV_DEFAULT symbols.

Benefits:

- Improves the size of object files by using fewer STT_SECTION symbols.
- Improves the assembly (as there are fewer  .Lfoo$local  labels).
- The code reads a bit better (it was not obvious to me without going back to the code reviews why the canBenefitFromLocalAlias function currently doesn't consider visibility).
- Restores the effectiveness of the --wrap linker option and makes the behavior of --wrap consistent between LTO and normal builds references within a translation-unit. See comments on https://reviews.llvm.org/D73230 for more.


https://reviews.llvm.org/D85782

Files:
  llvm/lib/IR/Globals.cpp
  llvm/test/CodeGen/AArch64/emutls.ll
  llvm/test/CodeGen/ARM/emutls.ll
  llvm/test/CodeGen/X86/2008-03-12-ThreadLocalAlias.ll
  llvm/test/CodeGen/X86/code-model-elf-pic-nosip.ll
  llvm/test/CodeGen/X86/code-model-elf-pic-sip.ll
  llvm/test/CodeGen/X86/code-model-elf-pie.ll
  llvm/test/CodeGen/X86/code-model-elf.ll
  llvm/test/CodeGen/X86/semantic-interposition-comdat.ll
  llvm/test/CodeGen/X86/tailcallpic1.ll
  llvm/test/CodeGen/X86/tailcallpic3.ll
  llvm/test/CodeGen/X86/tailccpic1.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85782.284872.patch
Type: text/x-patch
Size: 73293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200811/7b5e36fc/attachment.bin>


More information about the llvm-commits mailing list