aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp39
1 files changed, 26 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 6943ce2..15b5942 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -2680,21 +2680,34 @@ MCSection *TargetLoweringObjectFileXCOFF::getSectionForFunctionDescriptor(
MCSection *TargetLoweringObjectFileXCOFF::getSectionForTOCEntry(
const MCSymbol *Sym, const TargetMachine &TM) const {
- // Use TE storage-mapping class when large code model is enabled so that
- // the chance of needing -bbigtoc is decreased. Also, the toc-entry for
- // EH info is never referenced directly using instructions so it can be
- // allocated with TE storage-mapping class.
- // The "_$TLSML" symbol for TLS local-dynamic mode requires XMC_TC, otherwise
- // the AIX assembler will complain.
+ const XCOFF::StorageMappingClass SMC = [](const MCSymbol *Sym,
+ const TargetMachine &TM) {
+ const MCSymbolXCOFF *XSym = cast<MCSymbolXCOFF>(Sym);
+
+ // The "_$TLSML" symbol for TLS local-dynamic mode requires XMC_TC,
+ // otherwise the AIX assembler will complain.
+ if (XSym->getSymbolTableName() == "_$TLSML")
+ return XCOFF::XMC_TC;
+
+ // Use large code model toc entries for ehinfo symbols as they are
+ // never referenced directly. The runtime loads their TOC entry
+ // addresses from the trace-back table.
+ if (XSym->isEHInfo())
+ return XCOFF::XMC_TE;
+
+ // If the symbol does not have a code model specified use the module value.
+ if (!XSym->hasPerSymbolCodeModel())
+ return TM.getCodeModel() == CodeModel::Large ? XCOFF::XMC_TE
+ : XCOFF::XMC_TC;
+
+ return XSym->getPerSymbolCodeModel() == MCSymbolXCOFF::CM_Large
+ ? XCOFF::XMC_TE
+ : XCOFF::XMC_TC;
+ }(Sym, TM);
+
return getContext().getXCOFFSection(
cast<MCSymbolXCOFF>(Sym)->getSymbolTableName(), SectionKind::getData(),
- XCOFF::CsectProperties(
- ((TM.getCodeModel() == CodeModel::Large &&
- cast<MCSymbolXCOFF>(Sym)->getSymbolTableName() != "_$TLSML") ||
- cast<MCSymbolXCOFF>(Sym)->isEHInfo())
- ? XCOFF::XMC_TE
- : XCOFF::XMC_TC,
- XCOFF::XTY_SD));
+ XCOFF::CsectProperties(SMC, XCOFF::XTY_SD));
}
MCSection *TargetLoweringObjectFileXCOFF::getSectionForLSDA(