diff options
author | Xing Xue <xingxue@outlook.com> | 2022-05-05 09:01:36 -0400 |
---|---|---|
committer | Xing Xue <xingxue@outlook.com> | 2022-05-05 09:01:36 -0400 |
commit | e5926906eb1afd7ddacc1461296267b8d62da895 (patch) | |
tree | 3193b612ee3eb06fb395f4ab737d2364714677d6 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | |
parent | 75f9e83ace52773af65dcebca543005ec8a2705d (diff) | |
download | llvm-e5926906eb1afd7ddacc1461296267b8d62da895.zip llvm-e5926906eb1afd7ddacc1461296267b8d62da895.tar.gz llvm-e5926906eb1afd7ddacc1461296267b8d62da895.tar.bz2 |
[XCOFF][AIX] Use unique section names for LSDA and EH info sections with -ffunction-sections
Summary:
When -ffunction-sections is on, this patch makes the compiler to generate unique LSDA and EH info sections for functions on AIX by appending the function name to the section name as a suffix. This will allow the AIX linker to garbage-collect unused function.
Reviewed by: MaskRay, hubert.reinterpretcast
Differential Revision: https://reviews.llvm.org/D124855
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 3246d77..d34ba6f 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -2565,6 +2565,20 @@ MCSection *TargetLoweringObjectFileXCOFF::getSectionForTOCEntry( XCOFF::XTY_SD)); } +MCSection *TargetLoweringObjectFileXCOFF::getSectionForLSDA( + const Function &F, const MCSymbol &FnSym, const TargetMachine &TM) const { + auto *LSDA = cast<MCSectionXCOFF>(LSDASection); + if (TM.getFunctionSections()) { + // If option -ffunction-sections is on, append the function name to the + // name of the LSDA csect so that each function has its own LSDA csect. + // This helps the linker to garbage-collect EH info of unused functions. + SmallString<128> NameStr = LSDA->getName(); + raw_svector_ostream(NameStr) << '.' << F.getName(); + LSDA = getContext().getXCOFFSection(NameStr, LSDA->getKind(), + LSDA->getCsectProp()); + } + return LSDA; +} //===----------------------------------------------------------------------===// // GOFF //===----------------------------------------------------------------------===// |