From 5ce0a26bd1cd7fb3d815fd5f03c55dcdac5482c4 Mon Sep 17 00:00:00 2001 From: esmeyi Date: Wed, 11 Jan 2023 23:27:47 -0500 Subject: [XCOFF] handle the toc-data for object file generation. Summary: The toc-data feature has been supported for assembly file generation. This patch handles the toc-data for object file generation. Reviewed By: shchenz Differential Revision: https://reviews.llvm.org/D139516 --- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp') diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index b2d56adfbeab..e760564779c2 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -2292,16 +2292,16 @@ TargetLoweringObjectFileXCOFF::getTargetSymbol(const GlobalValue *GV, // function entry point. We choose to always return a function descriptor // here. if (const GlobalObject *GO = dyn_cast(GV)) { + if (GO->isDeclarationForLinker()) + return cast(getSectionForExternalReference(GO, TM)) + ->getQualNameSymbol(); + if (const GlobalVariable *GVar = dyn_cast(GV)) if (GVar->hasAttribute("toc-data")) return cast( SectionForGlobal(GVar, SectionKind::getData(), TM)) ->getQualNameSymbol(); - if (GO->isDeclarationForLinker()) - return cast(getSectionForExternalReference(GO, TM)) - ->getQualNameSymbol(); - SectionKind GOKind = getKindForGlobal(GO, TM); if (GOKind.isText()) return cast( @@ -2360,6 +2360,10 @@ MCSection *TargetLoweringObjectFileXCOFF::getSectionForExternalReference( if (GO->isThreadLocal()) SMC = XCOFF::XMC_UL; + if (const GlobalVariable *GVar = dyn_cast(GO)) + if (GVar->hasAttribute("toc-data")) + SMC = XCOFF::XMC_TD; + // Externals go into a csect of type ER. return getContext().getXCOFFSection( Name, SectionKind::getMetadata(), -- cgit v1.2.3