summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacques Pienaar <jpienaar@google.com>2018-02-08 23:25:05 +0000
committerJacques Pienaar <jpienaar@google.com>2018-02-08 23:25:05 +0000
commitbd275c7ba7e50861202219c793f650becd72f48f (patch)
treea28bcca9bb758b7b31508f84779461d7aa5c14b4
parentb7e13938a94cfa96968ad3beca9bd3d5c9e0d669 (diff)
downloadbcm5719-llvm-bd275c7ba7e50861202219c793f650becd72f48f.tar.gz
bcm5719-llvm-bd275c7ba7e50861202219c793f650becd72f48f.zip
[Lanai] Code model dictates section selection.
Always use the small section when the small code model is specified. llvm-svn: 324679
-rw-r--r--llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp b/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp
index 38e75108ba1..7d165e9c5f8 100644
--- a/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud