summaryrefslogtreecommitdiff
path: root/lib/Target/Lanai/LanaiTargetObjectFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/Lanai/LanaiTargetObjectFile.cpp')
-rw-r--r--lib/Target/Lanai/LanaiTargetObjectFile.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/Target/Lanai/LanaiTargetObjectFile.cpp b/lib/Target/Lanai/LanaiTargetObjectFile.cpp
index 38e75108ba16..7d165e9c5f8c 100644
--- a/lib/Target/Lanai/LanaiTargetObjectFile.cpp
+++ b/lib/Target/Lanai/LanaiTargetObjectFile.cpp
@@ -50,8 +50,7 @@ static bool isInSmallSection(uint64_t Size) {
// section.
bool LanaiTargetObjectFile::isGlobalInSmallSection(
const GlobalObject *GO, const TargetMachine &TM) const {
- if (GO == nullptr)
- return false;
+ if (GO == nullptr) return TM.getCodeModel() == CodeModel::Small;
// We first check the case where global is a declaration, because finding
// section kind using getKindForGlobal() is only allowed for global
@@ -67,8 +66,7 @@ bool LanaiTargetObjectFile::isGlobalInSmallSection(
bool LanaiTargetObjectFile::isGlobalInSmallSection(const GlobalObject *GO,
const TargetMachine &TM,
SectionKind Kind) const {
- return (isGlobalInSmallSectionImpl(GO, TM) &&
- (Kind.isData() || Kind.isBSS() || Kind.isCommon()));
+ return isGlobalInSmallSectionImpl(GO, TM);
}
// Return true if this global address should be placed into small data/bss
@@ -76,10 +74,10 @@ bool LanaiTargetObjectFile::isGlobalInSmallSection(const GlobalObject *GO,
// kind.
bool LanaiTargetObjectFile::isGlobalInSmallSectionImpl(
const GlobalObject *GO, const TargetMachine &TM) const {
- // Only global variables, not functions.
const auto *GVA = dyn_cast<GlobalVariable>(GO);
- if (!GVA)
- return false;
+
+ // If not a GlobalVariable, only consider the code model.
+ if (!GVA) return TM.getCodeModel() == CodeModel::Small;
// Global values placed in sections starting with .ldata do not fit in
// 21-bits, so always use large memory access for them. FIXME: This is a