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
committerGitHub <noreply@github.com>2023-11-28 12:55:17 -0800
commit38e435895779c6f0e6c47a171f3b300ad99828b3 (patch)
treecefc1e8fbb0f1f5319322f0f1ae84fed5df3e235 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent6989859254e8ce486d21d5a981c7fddf7964c7ad (diff)
downloadllvm-38e435895779c6f0e6c47a171f3b300ad99828b3.zip
llvm-38e435895779c6f0e6c47a171f3b300ad99828b3.tar.gz
llvm-38e435895779c6f0e6c47a171f3b300ad99828b3.tar.bz2
[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.
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};
}