From c77659e5494e4aa942bf0bc709b1779931dd30a8 Mon Sep 17 00:00:00 2001 From: Leonard Chan Date: Wed, 10 Feb 2021 09:59:36 -0800 Subject: [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 --- llvm/lib/CodeGen/MachineFunction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/MachineFunction.cpp') diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 3f90df1..0140738 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -1119,7 +1119,7 @@ unsigned MachineConstantPoolEntry::getSizeInBytes(const DataLayout &DL) const { bool MachineConstantPoolEntry::needsRelocation() const { if (isMachineConstantPoolEntry()) return true; - return Val.ConstVal->needsRelocation(); + return Val.ConstVal->needsDynamicRelocation(); } SectionKind -- cgit v1.1