[all-commits] [llvm/llvm-project] c77659: [llvm][IR] Do not place constants with static relo...

Leonard Chan via All-commits all-commits at lists.llvm.org
Thu Feb 18 15:40:02 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c77659e5494e4aa942bf0bc709b1779931dd30a8
      https://github.com/llvm/llvm-project/commit/c77659e5494e4aa942bf0bc709b1779931dd30a8
  Author: Leonard Chan <leonardchan at google.com>
  Date:   2021-02-18 (Thu, 18 Feb 2021)

  Changed paths:
    M llvm/include/llvm/IR/Constant.h
    M llvm/lib/CodeGen/MachineFunction.cpp
    M llvm/lib/IR/Constants.cpp
    M llvm/lib/Target/ARM/ARMISelLowering.cpp
    M llvm/lib/Target/ARM/ARMTargetTransformInfo.h
    M llvm/lib/Target/PowerPC/PPCTargetObjectFile.cpp
    M llvm/lib/Target/TargetLoweringObjectFile.cpp
    M llvm/test/CodeGen/X86/relptr-rodata.ll

  Log Message:
  -----------
  [llvm][IR] Do not place constants with static relocations in a mergeable section

This patch provides two major changes:

1. Add getRelocationInfo to check if a constant will have static, dynamic, or
   no relocations. (Also rename the original needsRelocation to needsDynamicRelocation.)
2. Only allow a constant with no relocations (static or dynamic) to be placed
   in a mergeable section.

This will allow unused symbols that contain static relocations and happen to
fit in mergeable constant sections (.rodata.cstN) to instead be placed in
unique-named sections if -fdata-sections is used and subsequently garbage collected
by --gc-sections.

See https://lists.llvm.org/pipermail/llvm-dev/2021-February/148281.html.

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




More information about the All-commits mailing list