aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorjasonliu <jasonliu.development@gmail.com>2020-08-06 13:19:59 +0000
committerjasonliu <jasonliu.development@gmail.com>2020-08-06 14:31:04 +0000
commite5062a6caf754de30b4ecba5bf670ee250f78554 (patch)
treecd2d360cb65833bf2e0024b25541f839ab124a1e /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent5a503521e7b757bda70325f4c01bdbc0f4e3128e (diff)
downloadllvm-e5062a6caf754de30b4ecba5bf670ee250f78554.zip
llvm-e5062a6caf754de30b4ecba5bf670ee250f78554.tar.gz
llvm-e5062a6caf754de30b4ecba5bf670ee250f78554.tar.bz2
[XCOFF][AIX] Put each jump table in an independent section if -ffunction-sections is specified
If a function is in a unique section, putting all jump tables in .rodata will prevent functions that have a jump table to get garbage collect by the linker. Therefore, we need to put jump table into a unique section as well. Reviewed By: Xiangling_L Differential Revision: https://reviews.llvm.org/D84761
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 8ef9125..fc08fb9 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -2085,11 +2085,18 @@ MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal(
MCSection *TargetLoweringObjectFileXCOFF::getSectionForJumpTable(
const Function &F, const TargetMachine &TM) const {
- assert (!TM.getFunctionSections() && "Unique sections not supported on XCOFF"
- " yet.");
assert (!F.getComdat() && "Comdat not supported on XCOFF.");
- //TODO: Enable emiting jump table to unique sections when we support it.
- return ReadOnlySection;
+
+ if (!TM.getFunctionSections())
+ return ReadOnlySection;
+
+ // If the function can be removed, produce a unique section so that
+ // the table doesn't prevent the removal.
+ SmallString<128> NameStr(".rodata.jmp..");
+ getNameWithPrefix(NameStr, &F, TM);
+ return getContext().getXCOFFSection(NameStr, XCOFF::XMC_RO, XCOFF::XTY_SD,
+ XCOFF::C_HIDEXT,
+ SectionKind::getReadOnly());
}
bool TargetLoweringObjectFileXCOFF::shouldPutJumpTableInFunctionSection(