diff options
author | Daniel Jasper <djasper@google.com> | 2014-02-19 12:26:01 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-02-19 12:26:01 +0000 |
commit | 7e198ad862cddf373edcb51801a9800c4637d52e (patch) | |
tree | 7a97a155d36e3ccc331ec56d3e18a7eefae5c408 /llvm/lib/CodeGen | |
parent | d495642c5410f11345c03fcaa35fd346ad9ab207 (diff) | |
download | bcm5719-llvm-7e198ad862cddf373edcb51801a9800c4637d52e.tar.gz bcm5719-llvm-7e198ad862cddf373edcb51801a9800c4637d52e.zip |
Revert r201622 and r201608.
This causes the LLVMgold plugin to segfault. More information on the
replies to r201608.
llvm-svn: 201669
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 15 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringBase.cpp | 29 | ||||
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 123 |
6 files changed, 52 insertions, 123 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 6c4cddc3f6e..63b4bb4296c 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -311,13 +311,8 @@ void AsmPrinter::EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const { llvm_unreachable("Unknown linkage type!"); } -void AsmPrinter::getNameWithPrefix(SmallVectorImpl<char> &Name, - const GlobalValue *GV) const { - TM.getTargetLowering()->getNameWithPrefix(Name, GV, *Mang); -} - MCSymbol *AsmPrinter::getSymbol(const GlobalValue *GV) const { - return TM.getTargetLowering()->getSymbol(GV, *Mang); + return getObjFileLowering().getSymbol(GV, *Mang); } /// EmitGlobalVariable - Emit the specified global variable to the .s file. @@ -1374,7 +1369,7 @@ void AsmPrinter::EmitLLVMUsedList(const ConstantArray *InitList) { for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) { const GlobalValue *GV = dyn_cast<GlobalValue>(InitList->getOperand(i)->stripPointerCasts()); - if (GV && getObjFileLowering().shouldEmitUsedDirectiveFor(GV, *Mang, TM)) + if (GV && getObjFileLowering().shouldEmitUsedDirectiveFor(GV, *Mang)) OutStreamer.EmitSymbolAttribute(getSymbol(GV), MCSA_NoDeadStrip); } } @@ -1579,8 +1574,7 @@ static const MCExpr *lowerConstant(const Constant *CV, AsmPrinter &AP) { } if (const MCExpr *RelocExpr = - AP.getObjFileLowering().getExecutableRelativeSymbol(CE, *AP.Mang, - AP.TM)) + AP.getObjFileLowering().getExecutableRelativeSymbol(CE, *AP.Mang)) return RelocExpr; switch (CE->getOpcode()) { @@ -2109,8 +2103,7 @@ MCSymbol *AsmPrinter::GetJTSetSymbol(unsigned UID, unsigned MBBID) const { MCSymbol *AsmPrinter::getSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix) const { - return getObjFileLowering().getSymbolWithGlobalValueBase(GV, Suffix, *Mang, - TM); + return getObjFileLowering().getSymbolWithGlobalValueBase(GV, Suffix, *Mang); } /// GetExternalSymbolSymbol - Return the MCSymbol for the specified diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp index 5f23e12eac8..94198c4af17 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp @@ -143,7 +143,7 @@ void AsmPrinter::EmitTTypeReference(const GlobalValue *GV, const TargetLoweringObjectFile &TLOF = getObjFileLowering(); const MCExpr *Exp = - TLOF.getTTypeGlobalReference(GV, Encoding, *Mang, TM, MMI, OutStreamer); + TLOF.getTTypeGlobalReference(GV, Encoding, *Mang, MMI, OutStreamer); OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding)); } else OutStreamer.EmitIntValue(0, GetSizeOfEncodedValue(Encoding)); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp index 30312ac2e28..ed51f50c40e 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp @@ -119,8 +119,7 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) { if (!shouldEmitPersonality) return; - const MCSymbol *Sym = - TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, Asm->TM, MMI); + const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, MMI); Asm->OutStreamer.EmitCFIPersonality(Sym, PerEncoding); Asm->OutStreamer.EmitDebugLabel diff --git a/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp b/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp index 17d8bff6092..eda444bd692 100644 --- a/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp @@ -101,8 +101,7 @@ void Win64Exception::endFunction(const MachineFunction *) { if (shouldEmitPersonality) { const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); const Function *Per = MMI->getPersonalities()[MMI->getPersonalityIndex()]; - const MCSymbol *Sym = - TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, Asm->TM, MMI); + const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, MMI); Asm->OutStreamer.PushSection(); Asm->OutStreamer.EmitWin64EHHandlerData(); diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index d3c42be5e6c..bdcb7216a56 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -24,9 +24,7 @@ #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/GlobalVariable.h" -#include "llvm/IR/Mangler.h" #include "llvm/MC/MCAsmInfo.h" -#include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" @@ -1428,30 +1426,3 @@ bool TargetLoweringBase::isLegalAddressingMode(const AddrMode &AM, return true; } - -void TargetLoweringBase::getNameWithPrefix(SmallVectorImpl<char> &Name, - const GlobalValue *GV, - Mangler &Mang, - bool MayAlwaysUsePrivate) const { - if (MayAlwaysUsePrivate || !GV->hasPrivateLinkage()) { - // Simple case: If GV is not private, it is not important to find out if - // private labels are legal in this case or not. - Mang.getNameWithPrefix(Name, GV, false); - return; - } - SectionKind GVKind = - TargetLoweringObjectFile::getKindForGlobal(GV, getTargetMachine()); - const TargetLoweringObjectFile &TLOF = getObjFileLowering(); - const MCSection *TheSection = - TLOF.SectionForGlobal(GV, GVKind, Mang, getTargetMachine()); - bool CannotUsePrivateLabel = TLOF.isSectionAtomizableBySymbols(*TheSection); - Mang.getNameWithPrefix(Name, GV, CannotUsePrivateLabel); -} - -MCSymbol *TargetLoweringBase::getSymbol(const GlobalValue *GV, - Mangler &Mang) const { - SmallString<60> NameStr; - getNameWithPrefix(NameStr, GV, Mang); - const TargetLoweringObjectFile &TLOF = getObjFileLowering(); - return TLOF.getContext().GetOrCreateSymbol(NameStr.str()); -} diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index bd54a871ca3..127b2aa324d 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -36,7 +36,6 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetLowering.h" using namespace llvm; using namespace dwarf; @@ -44,18 +43,19 @@ using namespace dwarf; // ELF //===----------------------------------------------------------------------===// -MCSymbol *TargetLoweringObjectFileELF::getCFIPersonalitySymbol( - const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM, - MachineModuleInfo *MMI) const { +MCSymbol * +TargetLoweringObjectFileELF::getCFIPersonalitySymbol(const GlobalValue *GV, + Mangler &Mang, + MachineModuleInfo *MMI) const { unsigned Encoding = getPersonalityEncoding(); switch (Encoding & 0x70) { default: report_fatal_error("We do not support this DWARF encoding yet!"); case dwarf::DW_EH_PE_absptr: - return TM.getTargetLowering()->getSymbol(GV, Mang); + return getSymbol(GV, Mang); case dwarf::DW_EH_PE_pcrel: { return getContext().GetOrCreateSymbol(StringRef("DW.ref.") + - TM.getTargetLowering()->getSymbol(GV, Mang)->getName()); + getSymbol(GV, Mang)->getName()); } } } @@ -89,19 +89,18 @@ void TargetLoweringObjectFileELF::emitPersonalityValue(MCStreamer &Streamer, const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference( const GlobalValue *GV, unsigned Encoding, Mangler &Mang, - const TargetMachine &TM, MachineModuleInfo *MMI, - MCStreamer &Streamer) const { + MachineModuleInfo *MMI, MCStreamer &Streamer) const { if (Encoding & dwarf::DW_EH_PE_indirect) { MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>(); - MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", Mang, TM); + MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", Mang); // Add information about the stub reference to ELFMMI so that the stub // gets emitted by the asmprinter. MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym); if (StubSym.getPointer() == 0) { - MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang); + MCSymbol *Sym = getSymbol(GV, Mang); StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); } @@ -110,8 +109,8 @@ const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference( Encoding & ~dwarf::DW_EH_PE_indirect, Streamer); } - return TargetLoweringObjectFile:: - getTTypeGlobalReference(GV, Encoding, Mang, TM, MMI, Streamer); + return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding, Mang, + MMI, Streamer); } static SectionKind @@ -196,9 +195,10 @@ getELFSectionFlags(SectionKind K) { return Flags; } -const MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal( - const GlobalValue *GV, SectionKind Kind, Mangler &Mang, - const TargetMachine &TM) const { + +const MCSection *TargetLoweringObjectFileELF:: +getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler &Mang, const TargetMachine &TM) const { StringRef SectionName = GV->getSection(); // Infer section flags from the section name if we can. @@ -248,12 +248,12 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Prefix = getSectionPrefixForGlobal(Kind); SmallString<128> Name(Prefix, Prefix+strlen(Prefix)); - TM.getTargetLowering()->getNameWithPrefix(Name, GV, Mang, true); - + MCSymbol *Sym = getSymbol(GV, Mang); + Name.append(Sym->getName().begin(), Sym->getName().end()); StringRef Group = ""; unsigned Flags = getELFSectionFlags(Kind); if (GV->isWeakForLinker()) { - Group = Name.substr(strlen(Prefix)); + Group = Sym->getName(); Flags |= ELF::SHF_GROUP; } @@ -487,9 +487,9 @@ emitModuleFlags(MCStreamer &Streamer, Streamer.AddBlankLine(); } -const MCSection *TargetLoweringObjectFileMachO::getExplicitSectionGlobal( - const GlobalValue *GV, SectionKind Kind, Mangler &Mang, - const TargetMachine &TM) const { +const MCSection *TargetLoweringObjectFileMachO:: +getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler &Mang, const TargetMachine &TM) const { // Parse the section specifier and create it if valid. StringRef Segment, Section; unsigned TAA = 0, StubSize = 0; @@ -526,41 +526,6 @@ const MCSection *TargetLoweringObjectFileMachO::getExplicitSectionGlobal( return S; } -bool TargetLoweringObjectFileMachO::isSectionAtomizableBySymbols( - const MCSection &Section) const { - const MCSectionMachO &SMO = static_cast<const MCSectionMachO&>(Section); - - // Sections holding 1 byte strings are atomized based on the data - // they contain. - // Sections holding 2 byte strings require symbols in order to be - // atomized. - // There is no dedicated section for 4 byte strings. - if (SMO.getKind().isMergeable1ByteCString()) - return false; - - if (SMO.getSegmentName() == "__DATA" && - SMO.getSectionName() == "__cfstring") - return false; - - switch (SMO.getType()) { - default: - return true; - - // These sections are atomized at the element boundaries without using - // symbols. - case MCSectionMachO::S_4BYTE_LITERALS: - case MCSectionMachO::S_8BYTE_LITERALS: - case MCSectionMachO::S_16BYTE_LITERALS: - case MCSectionMachO::S_LITERAL_POINTERS: - case MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS: - case MCSectionMachO::S_LAZY_SYMBOL_POINTERS: - case MCSectionMachO::S_MOD_INIT_FUNC_POINTERS: - case MCSectionMachO::S_MOD_TERM_FUNC_POINTERS: - case MCSectionMachO::S_INTERPOSING: - return false; - } -} - const MCSection *TargetLoweringObjectFileMachO:: SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang, const TargetMachine &TM) const { @@ -641,17 +606,21 @@ TargetLoweringObjectFileMachO::getSectionForConstant(SectionKind Kind) const { return ReadOnlySection; // .const } -/// This hook allows targets to selectively decide not to emit the UsedDirective -/// for some symbols in llvm.used. +/// shouldEmitUsedDirectiveFor - This hook allows targets to selectively decide +/// not to emit the UsedDirective for some symbols in llvm.used. // FIXME: REMOVE this (rdar://7071300) -bool TargetLoweringObjectFileMachO::shouldEmitUsedDirectiveFor( - const GlobalValue *GV, Mangler &Mang, TargetMachine &TM) const { +bool TargetLoweringObjectFileMachO:: +shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler &Mang) const { + /// On Darwin, internally linked data beginning with "L" or "l" does not have + /// the directive emitted (this occurs in ObjC metadata). + if (!GV) return false; + // Check whether the mangled name has the "Private" or "LinkerPrivate" prefix. if (GV->hasLocalLinkage() && !isa<Function>(GV)) { // FIXME: ObjC metadata is currently emitted as internal symbols that have // \1L and \0l prefixes on them. Fix them to be Private/LinkerPrivate and // this horrible hack can go away. - MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang); + MCSymbol *Sym = getSymbol(GV, Mang); if (Sym->getName()[0] == 'L' || Sym->getName()[0] == 'l') return false; } @@ -661,16 +630,14 @@ bool TargetLoweringObjectFileMachO::shouldEmitUsedDirectiveFor( const MCExpr *TargetLoweringObjectFileMachO::getTTypeGlobalReference( const GlobalValue *GV, unsigned Encoding, Mangler &Mang, - const TargetMachine &TM, MachineModuleInfo *MMI, - MCStreamer &Streamer) const { + MachineModuleInfo *MMI, MCStreamer &Streamer) const { // The mach-o version of this method defaults to returning a stub reference. if (Encoding & DW_EH_PE_indirect) { MachineModuleInfoMachO &MachOMMI = MMI->getObjFileInfo<MachineModuleInfoMachO>(); - MCSymbol *SSym = - getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr", Mang, TM); + MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr", Mang); // Add information about the stub reference to MachOMMI so that the stub // gets emitted by the asmprinter. @@ -678,7 +645,7 @@ const MCExpr *TargetLoweringObjectFileMachO::getTTypeGlobalReference( GV->hasHiddenVisibility() ? MachOMMI.getHiddenGVStubEntry(SSym) : MachOMMI.getGVStubEntry(SSym); if (StubSym.getPointer() == 0) { - MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang); + MCSymbol *Sym = getSymbol(GV, Mang); StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); } @@ -687,24 +654,24 @@ const MCExpr *TargetLoweringObjectFileMachO::getTTypeGlobalReference( Encoding & ~dwarf::DW_EH_PE_indirect, Streamer); } - return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding, Mang, - TM, MMI, Streamer); + return TargetLoweringObjectFile:: + getTTypeGlobalReference(GV, Encoding, Mang, MMI, Streamer); } -MCSymbol *TargetLoweringObjectFileMachO::getCFIPersonalitySymbol( - const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM, - MachineModuleInfo *MMI) const { +MCSymbol *TargetLoweringObjectFileMachO:: +getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang, + MachineModuleInfo *MMI) const { // The mach-o version of this method defaults to returning a stub reference. MachineModuleInfoMachO &MachOMMI = MMI->getObjFileInfo<MachineModuleInfoMachO>(); - MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr", Mang, TM); + MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr", Mang); // Add information about the stub reference to MachOMMI so that the stub // gets emitted by the asmprinter. MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym); if (StubSym.getPointer() == 0) { - MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang); + MCSymbol *Sym = getSymbol(GV, Mang); StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); } @@ -750,9 +717,9 @@ getCOFFSectionFlags(SectionKind K) { return Flags; } -const MCSection *TargetLoweringObjectFileCOFF::getExplicitSectionGlobal( - const GlobalValue *GV, SectionKind Kind, Mangler &Mang, - const TargetMachine &TM) const { +const MCSection *TargetLoweringObjectFileCOFF:: +getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler &Mang, const TargetMachine &TM) const { int Selection = 0; unsigned Characteristics = getCOFFSectionFlags(Kind); StringRef Name = GV->getSection(); @@ -760,7 +727,7 @@ const MCSection *TargetLoweringObjectFileCOFF::getExplicitSectionGlobal( if (GV->isWeakForLinker()) { Selection = COFF::IMAGE_COMDAT_SELECT_ANY; Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT; - MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang); + MCSymbol *Sym = getSymbol(GV, Mang); COMDATSymName = Sym->getName(); } return getContext().getCOFFSection(Name, @@ -794,7 +761,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, unsigned Characteristics = getCOFFSectionFlags(Kind); Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT; - MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang); + MCSymbol *Sym = getSymbol(GV, Mang); return getContext().getCOFFSection(Name, Characteristics, Kind, Sym->getName(), COFF::IMAGE_COMDAT_SELECT_ANY); |