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-11-30 15:17:17 -0800
commit4bf8a688956a759b7b6b8d94f42d25c13c7af130 (patch)
tree838e86762973522869441295b69641906a74493e /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent87e22bdd2bd6d77d782f9d64b3e3ae5bdcd5080d (diff)
downloadllvm-4bf8a688956a759b7b6b8d94f42d25c13c7af130.zip
llvm-4bf8a688956a759b7b6b8d94f42d25c13c7af130.tar.gz
llvm-4bf8a688956a759b7b6b8d94f42d25c13c7af130.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.
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};
}