diff options
author | jasonliu <jasonliu.development@gmail.com> | 2020-07-29 15:06:04 +0000 |
---|---|---|
committer | jasonliu <jasonliu.development@gmail.com> | 2020-07-30 13:30:01 +0000 |
commit | 04dc9691ebef740cc8dc85e9a5d7a3e1ed595765 (patch) | |
tree | d12004b44c8e4e7d2ae65931822ba487dca2067b /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | |
parent | f7237ee74fa629a4e79abf4bd3bc2e4d2b5d8a0a (diff) | |
download | llvm-04dc9691ebef740cc8dc85e9a5d7a3e1ed595765.zip llvm-04dc9691ebef740cc8dc85e9a5d7a3e1ed595765.tar.gz llvm-04dc9691ebef740cc8dc85e9a5d7a3e1ed595765.tar.bz2 |
[XCOFF][AIX] Enable -ffunction-sections
Summary:
This patch implements -ffunction-sections on AIX.
This patch focuses on assembly generation.
Follow-on patch needs to handle:
1. -ffunction-sections implication for jump table.
2. Object file generation path and associated testing.
Differential Revision: https://reviews.llvm.org/D83875
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index bf3b89e..4859919 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -2027,8 +2027,8 @@ MCSection *TargetLoweringObjectFileXCOFF::getSectionForExternalReference( MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal( const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const { - assert(!TM.getFunctionSections() && !TM.getDataSections() && - "XCOFF unique sections not yet implemented."); + assert(!TM.getDataSections() && + "XCOFF unique data sections not yet implemented."); // Common symbols go into a csect with matching name which will get mapped // into the .bss section. @@ -2057,8 +2057,13 @@ MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal( Kind, /* BeginSymbolName */ nullptr); } - if (Kind.isText()) + if (Kind.isText()) { + if (TM.getFunctionSections()) { + return cast<MCSymbolXCOFF>(getFunctionEntryPointSymbol(GO, TM)) + ->getRepresentedCsect(); + } return TextSection; + } if (Kind.isData() || Kind.isReadOnlyWithRel()) // TODO: We may put this under option control, because user may want to @@ -2161,6 +2166,22 @@ MCSymbol *TargetLoweringObjectFileXCOFF::getFunctionEntryPointSymbol( SmallString<128> NameStr; NameStr.push_back('.'); getNameWithPrefix(NameStr, Func, TM); + + // When -function-sections is enabled, it's not necessary to emit + // function entry point label any more. We will use function entry + // point csect instead. For function delcarations, it's okay to continue + // using label semantic because undefined symbols gets treated as csect with + // XTY_ER property anyway. + if (TM.getFunctionSections() && !Func->isDeclaration() && + isa<Function>(Func)) { + XCOFF::StorageClass SC = + TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(Func); + return cast<MCSectionXCOFF>(getContext().getXCOFFSection( + NameStr, XCOFF::XMC_PR, XCOFF::XTY_SD, SC, + SectionKind::getText())) + ->getQualNameSymbol(); + } + return getContext().getOrCreateSymbol(NameStr); } |