aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorArthur Eubanks <aeubanks@google.com>2023-11-28 12:55:17 -0800
committerArthur Eubanks <aeubanks@google.com>2023-12-01 14:23:44 -0800
commitd8a04398f9492f043ffd8fbaf2458778f7d0fcd5 (patch)
treec867830e6d7e7dc8b5d64299f756cdd36ca60ed5 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent8206b75a1e8d2e00e9bc47ba8288dec1205fbd91 (diff)
downloadllvm-d8a04398f9492f043ffd8fbaf2458778f7d0fcd5.zip
llvm-d8a04398f9492f043ffd8fbaf2458778f7d0fcd5.tar.gz
llvm-d8a04398f9492f043ffd8fbaf2458778f7d0fcd5.tar.bz2
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.
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index f3ba38081..143a495 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<GlobalVariable>(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<GlobalVariable>(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};
}