From b4aaffffd3473d7eff7fc63d022ed4e9549983ea Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 19 Feb 2014 20:30:41 +0000 Subject: move getNameWithPrefix and getSymbol to TargetMachine. TargetLoweringBase is implemented in CodeGen, so before this patch we had a dependency fom Target to CodeGen. This would show up as a link failure of llvm-stress when building with -DBUILD_SHARED_LIBS=ON. This fixes pr18900. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201711 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 4 ++-- lib/CodeGen/TargetLoweringBase.cpp | 27 --------------------------- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 18 +++++++++--------- 3 files changed, 11 insertions(+), 38 deletions(-) (limited to 'lib/CodeGen') diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 6c4cddc3f6..6ed2991ded 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -313,11 +313,11 @@ void AsmPrinter::EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const { void AsmPrinter::getNameWithPrefix(SmallVectorImpl &Name, const GlobalValue *GV) const { - TM.getTargetLowering()->getNameWithPrefix(Name, GV, *Mang); + TM.getNameWithPrefix(Name, GV, *Mang); } MCSymbol *AsmPrinter::getSymbol(const GlobalValue *GV) const { - return TM.getTargetLowering()->getSymbol(GV, *Mang); + return TM.getSymbol(GV, *Mang); } /// EmitGlobalVariable - Emit the specified global variable to the .s file. diff --git a/lib/CodeGen/TargetLoweringBase.cpp b/lib/CodeGen/TargetLoweringBase.cpp index d3c42be5e6..47a86d601b 100644 --- a/lib/CodeGen/TargetLoweringBase.cpp +++ b/lib/CodeGen/TargetLoweringBase.cpp @@ -1428,30 +1428,3 @@ bool TargetLoweringBase::isLegalAddressingMode(const AddrMode &AM, return true; } - -void TargetLoweringBase::getNameWithPrefix(SmallVectorImpl &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/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index bd54a871ca..0f3fb4924b 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -52,10 +52,10 @@ MCSymbol *TargetLoweringObjectFileELF::getCFIPersonalitySymbol( 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 TM.getSymbol(GV, Mang); case dwarf::DW_EH_PE_pcrel: { return getContext().GetOrCreateSymbol(StringRef("DW.ref.") + - TM.getTargetLowering()->getSymbol(GV, Mang)->getName()); + TM.getSymbol(GV, Mang)->getName()); } } } @@ -101,7 +101,7 @@ const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference( // gets emitted by the asmprinter. MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym); if (StubSym.getPointer() == 0) { - MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang); + MCSymbol *Sym = TM.getSymbol(GV, Mang); StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); } @@ -248,7 +248,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Prefix = getSectionPrefixForGlobal(Kind); SmallString<128> Name(Prefix, Prefix+strlen(Prefix)); - TM.getTargetLowering()->getNameWithPrefix(Name, GV, Mang, true); + TM.getNameWithPrefix(Name, GV, Mang, true); StringRef Group = ""; unsigned Flags = getELFSectionFlags(Kind); @@ -651,7 +651,7 @@ bool TargetLoweringObjectFileMachO::shouldEmitUsedDirectiveFor( // 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 = TM.getSymbol(GV, Mang); if (Sym->getName()[0] == 'L' || Sym->getName()[0] == 'l') return false; } @@ -678,7 +678,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 = TM.getSymbol(GV, Mang); StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); } @@ -704,7 +704,7 @@ MCSymbol *TargetLoweringObjectFileMachO::getCFIPersonalitySymbol( // gets emitted by the asmprinter. MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym); if (StubSym.getPointer() == 0) { - MCSymbol *Sym = TM.getTargetLowering()->getSymbol(GV, Mang); + MCSymbol *Sym = TM.getSymbol(GV, Mang); StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); } @@ -760,7 +760,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 = TM.getSymbol(GV, Mang); COMDATSymName = Sym->getName(); } return getContext().getCOFFSection(Name, @@ -794,7 +794,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 = TM.getSymbol(GV, Mang); return getContext().getCOFFSection(Name, Characteristics, Kind, Sym->getName(), COFF::IMAGE_COMDAT_SELECT_ANY); -- cgit v1.2.3