diff options
author | jasonliu <jasonliu.development@gmail.com> | 2020-08-06 13:19:59 +0000 |
---|---|---|
committer | jasonliu <jasonliu.development@gmail.com> | 2020-08-06 14:31:04 +0000 |
commit | e5062a6caf754de30b4ecba5bf670ee250f78554 (patch) | |
tree | cd2d360cb65833bf2e0024b25541f839ab124a1e /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | |
parent | 5a503521e7b757bda70325f4c01bdbc0f4e3128e (diff) | |
download | llvm-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.cpp | 15 |
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( |