diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-10-24 19:23:39 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-10-24 19:23:39 +0000 |
commit | 6733564e5aff326bffb858fb0b2358905b792f24 (patch) | |
tree | 3aa98ff5a91ac560d2bbb54661df5bedd97e56d1 /llvm/lib/Target/TargetLoweringObjectFile.cpp | |
parent | 87eea10711a610eee827258d510ef9a34dfab73a (diff) | |
download | bcm5719-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/TargetLoweringObjectFile.cpp')
-rw-r--r-- | llvm/lib/Target/TargetLoweringObjectFile.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp index ae80075c7f8..a8b2af18ebf 100644 --- a/llvm/lib/Target/TargetLoweringObjectFile.cpp +++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp @@ -132,15 +132,15 @@ void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer, /// classifies the global in a variety of ways that make various target /// implementations simpler. The target implementation is free to ignore this /// extra info of course. -SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV, +SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM){ - assert(!GV->isDeclaration() && !GV->hasAvailableExternallyLinkage() && + assert(!GO->isDeclaration() && !GO->hasAvailableExternallyLinkage() && "Can only be used for global definitions"); Reloc::Model ReloModel = TM.getRelocationModel(); // Early exit - functions should be always in text sections. - const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV); + const auto *GVar = dyn_cast<GlobalVariable>(GO); if (!GVar) return SectionKind::getText(); @@ -201,7 +201,8 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV, // Otherwise, just drop it into a mergable constant section. If we have // a section for this size, use it, otherwise use the arbitrary sized // mergable section. - switch (GV->getParent()->getDataLayout().getTypeAllocSize(C->getType())) { + switch ( + GVar->getParent()->getDataLayout().getTypeAllocSize(C->getType())) { case 4: return SectionKind::getMergeableConst4(); case 8: return SectionKind::getMergeableConst8(); case 16: return SectionKind::getMergeableConst16(); @@ -234,13 +235,13 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV, /// variable or function definition. This should not be passed external (or /// available externally) globals. MCSection *TargetLoweringObjectFile::SectionForGlobal( - const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const { + const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const { // Select section name. - if (GV->hasSection()) - return getExplicitSectionGlobal(GV, Kind, TM); + if (GO->hasSection()) + return getExplicitSectionGlobal(GO, Kind, TM); // Use default section depending on the 'type' of global - return SelectSectionForGlobal(GV, Kind, TM); + return SelectSectionForGlobal(GO, Kind, TM); } MCSection *TargetLoweringObjectFile::getSectionForJumpTable( |