X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FTargetLoweringObjectFile.cpp;h=a0b0d8f240465b7c8267893fd553b444ea4a1738;hb=134207508213455c8969a2e07115798619989154;hp=b8006ba03e56f211361c367af8e481cc3fce823f;hpb=4a867c7a05bd0560cc16b3c16286e1c76073334e;p=oota-llvm.git diff --git a/lib/Target/TargetLoweringObjectFile.cpp b/lib/Target/TargetLoweringObjectFile.cpp index b8006ba03e5..a0b0d8f2404 100644 --- a/lib/Target/TargetLoweringObjectFile.cpp +++ b/lib/Target/TargetLoweringObjectFile.cpp @@ -43,8 +43,7 @@ using namespace llvm; void TargetLoweringObjectFile::Initialize(MCContext &ctx, const TargetMachine &TM) { Ctx = &ctx; - DL = TM.getDataLayout(); - InitMCObjectFileInfo(Triple(TM.getTargetTriple()), TM.getRelocationModel(), + InitMCObjectFileInfo(TM.getTargetTriple(), TM.getRelocationModel(), TM.getCodeModel(), *Ctx); } @@ -107,7 +106,7 @@ MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase( assert(!Suffix.empty()); SmallString<60> NameStr; - NameStr += DL->getPrivateGlobalPrefix(); + NameStr += GV->getParent()->getDataLayout().getPrivateGlobalPrefix(); TM.getNameWithPrefix(NameStr, GV, Mang); NameStr.append(Suffix.begin(), Suffix.end()); return Ctx->getOrCreateSymbol(NameStr); @@ -120,7 +119,7 @@ MCSymbol *TargetLoweringObjectFile::getCFIPersonalitySymbol( } void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer, - const TargetMachine &TM, + const DataLayout &, const MCSymbol *Sym) const { } @@ -170,14 +169,13 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV, // If the initializer for the global contains something that requires a // relocation, then we may have to drop this into a writable data section // even though it is marked const. - switch (C->getRelocationInfo()) { - case Constant::NoRelocation: + if (!C->needsRelocation()) { // If the global is required to have a unique address, it can't be put // into a mergable section: just drop it into the general read-only // section instead. if (!GVar->hasUnnamedAddr()) return SectionKind::getReadOnly(); - + // If initializer is a null-terminated string, put it in a "cstring" // section of the right width. if (ArrayType *ATy = dyn_cast(C->getType())) { @@ -200,7 +198,7 @@ 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 (TM.getDataLayout()->getTypeAllocSize(C->getType())) { + switch (GV->getParent()->getDataLayout().getTypeAllocSize(C->getType())) { case 4: return SectionKind::getMergeableConst4(); case 8: return SectionKind::getMergeableConst8(); case 16: return SectionKind::getMergeableConst16(); @@ -208,20 +206,7 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV, return SectionKind::getReadOnly(); } - case Constant::LocalRelocation: - // In static relocation model, the linker will resolve all addresses, so - // the relocation entries will actually be constants by the time the app - // starts up. However, we can't put this into a mergable section, because - // the linker doesn't take relocations into consideration when it tries to - // merge entries in the section. - if (ReloModel == Reloc::Static) - return SectionKind::getReadOnly(); - - // Otherwise, the dynamic linker needs to fix it up, put it in the - // writable data.rel.local section. - return SectionKind::getReadOnlyWithRelLocal(); - - case Constant::GlobalRelocations: + } else { // In static relocation model, the linker will resolve all addresses, so // the relocation entries will actually be constants by the time the app // starts up. However, we can't put this into a mergable section, because @@ -242,17 +227,11 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV, // globals together onto fewer pages, improving the locality of the dynamic // linker. if (ReloModel == Reloc::Static) - return SectionKind::getDataNoRel(); - - switch (C->getRelocationInfo()) { - case Constant::NoRelocation: - return SectionKind::getDataNoRel(); - case Constant::LocalRelocation: - return SectionKind::getDataRelLocal(); - case Constant::GlobalRelocations: - return SectionKind::getDataRel(); - } - llvm_unreachable("Invalid relocation"); + return SectionKind::getData(); + + if (C->needsRelocation()) + return SectionKind::getData(); + return SectionKind::getData(); } /// This method computes the appropriate section to emit the specified global @@ -273,7 +252,8 @@ TargetLoweringObjectFile::SectionForGlobal(const GlobalValue *GV, MCSection *TargetLoweringObjectFile::getSectionForJumpTable( const Function &F, Mangler &Mang, const TargetMachine &TM) const { - return getSectionForConstant(SectionKind::getReadOnly(), /*C=*/nullptr); + return getSectionForConstant(F.getParent()->getDataLayout(), + SectionKind::getReadOnly(), /*C=*/nullptr); } bool TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection( @@ -296,9 +276,8 @@ bool TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection( /// Given a mergable constant with the specified size and relocation /// information, return a section that it should be placed in. -MCSection * -TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind, - const Constant *C) const { +MCSection *TargetLoweringObjectFile::getSectionForConstant( + const DataLayout &DL, SectionKind Kind, const Constant *C) const { if (Kind.isReadOnly() && ReadOnlySection != nullptr) return ReadOnlySection; @@ -345,7 +324,7 @@ const MCExpr *TargetLoweringObjectFile::getDebugThreadLocalSymbol(const MCSymbol } void TargetLoweringObjectFile::getNameWithPrefix( - SmallVectorImpl &OutName, const GlobalValue *GV, - bool CannotUsePrivateLabel, Mangler &Mang, const TargetMachine &TM) const { - Mang.getNameWithPrefix(OutName, GV, CannotUsePrivateLabel); + SmallVectorImpl &OutName, const GlobalValue *GV, Mangler &Mang, + const TargetMachine &TM) const { + Mang.getNameWithPrefix(OutName, GV, /*CannotUsePrivateLabel=*/false); }