summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJacques Pienaar <jpienaar@google.com>2016-12-15 16:56:16 +0000
committerJacques Pienaar <jpienaar@google.com>2016-12-15 16:56:16 +0000
commitccffe38352fe4042c7fb3bb36ba1e6fea9df9e34 (patch)
tree334036e6473808ee4cfbc16e805a7a923f05bc96 /llvm/lib
parent659949cb03c7c49a1a9c7096cf211311f5171846 (diff)
downloadbcm5719-llvm-ccffe38352fe4042c7fb3bb36ba1e6fea9df9e34.tar.gz
bcm5719-llvm-ccffe38352fe4042c7fb3bb36ba1e6fea9df9e34.zip
[lanai] Simplify small section check in LowerGlobalAddress and treat ldata sections specially.
Move the check for the code model into isGlobalInSmallSectionImpl and return false (not in small section) for variables placed in sections prefixed with .ldata (workaround for a tool limitation). llvm-svn: 289832
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/Lanai/LanaiISelLowering.cpp3
-rw-r--r--llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp14
2 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Target/Lanai/LanaiISelLowering.cpp b/llvm/lib/Target/Lanai/LanaiISelLowering.cpp
index c5627d21905..ae7870e07d4 100644
--- a/llvm/lib/Target/Lanai/LanaiISelLowering.cpp
+++ b/llvm/lib/Target/Lanai/LanaiISelLowering.cpp
@@ -1170,8 +1170,7 @@ SDValue LanaiTargetLowering::LowerGlobalAddress(SDValue Op,
// If the code model is small or global variable will be placed in the small
// section, then assume address will fit in 21-bits.
const GlobalObject *GO = GV->getBaseObject();
- if (getTargetMachine().getCodeModel() == CodeModel::Small ||
- (GO && TLOF->isGlobalInSmallSection(GO, getTargetMachine()))) {
+ if (TLOF->isGlobalInSmallSection(GO, getTargetMachine())) {
SDValue Small = DAG.getTargetGlobalAddress(
GV, DL, getPointerTy(DAG.getDataLayout()), Offset, LanaiII::MO_NO_FLAG);
return DAG.getNode(ISD::OR, DL, MVT::i32,
diff --git a/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp b/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp
index 4edb4f849da..7475dbd68ae 100644
--- a/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp
+++ b/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp
@@ -50,6 +50,9 @@ static bool isInSmallSection(uint64_t Size) {
// section.
bool LanaiTargetObjectFile::isGlobalInSmallSection(
const GlobalObject *GO, const TargetMachine &TM) const {
+ if (GO == nullptr)
+ return false;
+
// We first check the case where global is a declaration, because finding
// section kind using getKindForGlobal() is only allowed for global
// definitions.
@@ -72,12 +75,21 @@ bool LanaiTargetObjectFile::isGlobalInSmallSection(const GlobalObject *GO,
// section. This method does all the work, except for checking the section
// kind.
bool LanaiTargetObjectFile::isGlobalInSmallSectionImpl(
- const GlobalObject *GO, const TargetMachine & /*TM*/) const {
+ const GlobalObject *GO, const TargetMachine &TM) const {
// Only global variables, not functions.
const auto *GVA = dyn_cast<GlobalVariable>(GO);
if (!GVA)
return false;
+ // 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
+ // workaround for a tool limitation.
+ if (GVA->getSection().startswith(".ldata"))
+ return false;
+
+ if (TM.getCodeModel() == CodeModel::Small)
+ return true;
+
if (GVA->hasLocalLinkage())
return false;
OpenPOWER on IntegriCloud