From d8a04398f9492f043ffd8fbaf2458778f7d0fcd5 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Tue, 28 Nov 2023 12:55:17 -0800 Subject: Reland [X86] With large code model, put functions into .ltext with large section flag (#73037) So that when mixing small and large text, large text stays out of the way of the rest of the binary. This is useful for mixing precompiled small code model object files and built-from-source large code model binaries so that the the text sections don't get merged. The reland fixes an issue where a function in the large code model would reference small data without GOTOFF. This was incorrectly reverted in 76f78ecc789d58baa3a88b2fe2a57428f07e5362. --- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp') diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index f3ba38081890..143a4951c136 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -616,7 +616,7 @@ static unsigned getEntrySizeForKind(SectionKind Kind) { /// DataSections. static StringRef getSectionPrefixForGlobal(SectionKind Kind, bool IsLarge) { if (Kind.isText()) - return ".text"; + return IsLarge ? ".ltext" : ".text"; if (Kind.isReadOnly()) return IsLarge ? ".lrodata" : ".rodata"; if (Kind.isBSS()) @@ -650,10 +650,7 @@ getELFSectionNameForGlobal(const GlobalObject *GO, SectionKind Kind, Name = ".rodata.cst"; Name += utostr(EntrySize); } else { - bool IsLarge = false; - if (auto *GV = dyn_cast(GO)) - IsLarge = TM.isLargeData(GV); - Name = getSectionPrefixForGlobal(Kind, IsLarge); + Name = getSectionPrefixForGlobal(Kind, TM.isLargeGlobalObject(GO)); } bool HasPrefix = false; @@ -773,12 +770,8 @@ getGlobalObjectInfo(const GlobalObject *GO, const TargetMachine &TM) { Group = C->getName(); IsComdat = C->getSelectionKind() == Comdat::Any; } - if (auto *GV = dyn_cast(GO)) { - if (TM.isLargeData(GV)) { - assert(TM.getTargetTriple().getArch() == Triple::x86_64); - Flags |= ELF::SHF_X86_64_LARGE; - } - } + if (TM.isLargeGlobalObject(GO)) + Flags |= ELF::SHF_X86_64_LARGE; return {Group, IsComdat, Flags}; } -- cgit v1.2.3