summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-10-24 19:23:39 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-10-24 19:23:39 +0000
commit6733564e5aff326bffb858fb0b2358905b792f24 (patch)
tree3aa98ff5a91ac560d2bbb54661df5bedd97e56d1 /llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp
parent87eea10711a610eee827258d510ef9a34dfab73a (diff)
downloadbcm5719-llvm-6733564e5aff326bffb858fb0b2358905b792f24.tar.gz
bcm5719-llvm-6733564e5aff326bffb858fb0b2358905b792f24.zip
Target: Change various section classifiers in TargetLoweringObjectFile to take a GlobalObject.
These functions are about classifying a global which will actually be emitted, so it does not make sense for them to take a GlobalValue which may for example be an alias. Change the Mach-O object writer and the Hexagon, Lanai and MIPS backends to look through aliases before using TargetLoweringObjectFile interfaces. These are functional changes but all appear to be bug fixes. Differential Revision: https://reviews.llvm.org/D25917 llvm-svn: 285006
Diffstat (limited to 'llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp')
-rw-r--r--llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp b/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp
index b736a25c267..4edb4f849da 100644
--- a/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp
+++ b/llvm/lib/Target/Lanai/LanaiTargetObjectFile.cpp
@@ -49,22 +49,22 @@ static bool isInSmallSection(uint64_t Size) {
// Return true if this global address should be placed into small data/bss
// section.
bool LanaiTargetObjectFile::isGlobalInSmallSection(
- const GlobalValue *GV, const TargetMachine &TM) const {
+ const GlobalObject *GO, const TargetMachine &TM) const {
// We first check the case where global is a declaration, because finding
// section kind using getKindForGlobal() is only allowed for global
// definitions.
- if (GV->isDeclaration() || GV->hasAvailableExternallyLinkage())
- return isGlobalInSmallSectionImpl(GV, TM);
+ if (GO->isDeclaration() || GO->hasAvailableExternallyLinkage())
+ return isGlobalInSmallSectionImpl(GO, TM);
- return isGlobalInSmallSection(GV, TM, getKindForGlobal(GV, TM));
+ return isGlobalInSmallSection(GO, TM, getKindForGlobal(GO, TM));
}
// Return true if this global address should be placed into small data/bss
// section.
-bool LanaiTargetObjectFile::isGlobalInSmallSection(const GlobalValue *GV,
+bool LanaiTargetObjectFile::isGlobalInSmallSection(const GlobalObject *GO,
const TargetMachine &TM,
SectionKind Kind) const {
- return (isGlobalInSmallSectionImpl(GV, TM) &&
+ return (isGlobalInSmallSectionImpl(GO, TM) &&
(Kind.isData() || Kind.isBSS() || Kind.isCommon()));
}
@@ -72,34 +72,34 @@ bool LanaiTargetObjectFile::isGlobalInSmallSection(const GlobalValue *GV,
// section. This method does all the work, except for checking the section
// kind.
bool LanaiTargetObjectFile::isGlobalInSmallSectionImpl(
- const GlobalValue *GV, const TargetMachine & /*TM*/) const {
+ const GlobalObject *GO, const TargetMachine & /*TM*/) const {
// Only global variables, not functions.
- const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GV);
+ const auto *GVA = dyn_cast<GlobalVariable>(GO);
if (!GVA)
return false;
- if (GV->hasLocalLinkage())
+ if (GVA->hasLocalLinkage())
return false;
- if (((GV->hasExternalLinkage() && GV->isDeclaration()) ||
- GV->hasCommonLinkage()))
+ if (((GVA->hasExternalLinkage() && GVA->isDeclaration()) ||
+ GVA->hasCommonLinkage()))
return false;
- Type *Ty = GV->getType()->getElementType();
+ Type *Ty = GVA->getValueType();
return isInSmallSection(
- GV->getParent()->getDataLayout().getTypeAllocSize(Ty));
+ GVA->getParent()->getDataLayout().getTypeAllocSize(Ty));
}
MCSection *LanaiTargetObjectFile::SelectSectionForGlobal(
- const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
+ const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
// Handle Small Section classification here.
- if (Kind.isBSS() && isGlobalInSmallSection(GV, TM, Kind))
+ if (Kind.isBSS() && isGlobalInSmallSection(GO, TM, Kind))
return SmallBSSSection;
- if (Kind.isData() && isGlobalInSmallSection(GV, TM, Kind))
+ if (Kind.isData() && isGlobalInSmallSection(GO, TM, Kind))
return SmallDataSection;
// Otherwise, we work the same as ELF.
- return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, TM);
+ return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
}
/// Return true if this constant should be placed into small data section.
OpenPOWER on IntegriCloud