[PATCH] D95960: [llvm][IR] Do not place constants with static relocations in a mergeable section

Leonard Chan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 10:25:11 PST 2021


leonardchan created this revision.
leonardchan added reviewers: phosek, mcgrathr, pcc.
leonardchan added a project: LLVM.
Herald added subscribers: dexonsmith, pengfei, hiraditya.
leonardchan requested review of this revision.

This patch provides two major changes:

1. Add `needsStaticRelocation` to check if a constant will have dso_local relocations that can can be resolved by the static linker. (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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95960

Files:
  llvm/include/llvm/IR/Constant.h
  llvm/lib/IR/Constants.cpp
  llvm/lib/Target/TargetLoweringObjectFile.cpp
  llvm/test/CodeGen/X86/relptr-rodata.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95960.321143.patch
Type: text/x-patch
Size: 5322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210203/f884ea02/attachment.bin>


More information about the llvm-commits mailing list