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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285006 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Collingbourne
2016-10-24 19:23:39 +00:00
parent ddbec7c447
commit 80e2a2f817
25 changed files with 206 additions and 182 deletions
+6 -6
View File
@@ -96,8 +96,8 @@ static unsigned getXCoreSectionFlags(SectionKind K, bool IsCPRel) {
}
MCSection *XCoreTargetObjectFile::getExplicitSectionGlobal(
const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
StringRef SectionName = GV->getSection();
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
StringRef SectionName = GO->getSection();
// Infer section flags from the section name if we can.
bool IsCPRel = SectionName.startswith(".cp.");
if (IsCPRel && !Kind.isReadOnly())
@@ -107,9 +107,9 @@ MCSection *XCoreTargetObjectFile::getExplicitSectionGlobal(
}
MCSection *XCoreTargetObjectFile::SelectSectionForGlobal(
const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
bool UseCPRel = GV->isLocalLinkage(GV->getLinkage());
bool UseCPRel = GO->hasLocalLinkage();
if (Kind.isText()) return TextSection;
if (UseCPRel) {
@@ -118,8 +118,8 @@ MCSection *XCoreTargetObjectFile::SelectSectionForGlobal(
if (Kind.isMergeableConst8()) return MergeableConst8Section;
if (Kind.isMergeableConst16()) return MergeableConst16Section;
}
Type *ObjType = GV->getValueType();
auto &DL = GV->getParent()->getDataLayout();
Type *ObjType = GO->getValueType();
auto &DL = GO->getParent()->getDataLayout();
if (TM.getCodeModel() == CodeModel::Small || !ObjType->isSized() ||
DL.getTypeAllocSize(ObjType) < CodeModelLargeSize) {
if (Kind.isReadOnly()) return UseCPRel? ReadOnlySection