From b64fb453eaf3c2d768538571b2d99b4c5acf8911 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Tue, 22 Nov 2016 16:17:20 +0000 Subject: [PATCH] CodeGen: simplify TargetMachine::getSymbol interface. NFC. No-one actually had a mangler handy when calling this function, and getSymbol itself went most of the way towards getting its own mangler (with a local TLOF variable) so forcing all callers to supply one was just extra complication. llvm-svn: 287645 --- llvm/include/llvm/Target/TargetMachine.h | 2 +- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 +- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 21 ++++++++++----------- llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp | 4 ++-- llvm/lib/Target/ARM/ARMTargetObjectFile.cpp | 2 +- llvm/lib/Target/Sparc/SparcTargetObjectFile.cpp | 2 +- llvm/lib/Target/TargetLoweringObjectFile.cpp | 4 ++-- llvm/lib/Target/TargetMachine.cpp | 6 +++--- llvm/lib/Target/X86/X86TargetObjectFile.cpp | 6 +++--- 9 files changed, 24 insertions(+), 25 deletions(-) diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h index 32b3445..f549328 100644 --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/include/llvm/Target/TargetMachine.h @@ -261,7 +261,7 @@ public: void getNameWithPrefix(SmallVectorImpl &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate = false) const; - MCSymbol *getSymbol(const GlobalValue *GV, Mangler &Mang) const; + MCSymbol *getSymbol(const GlobalValue *GV) const; /// True if the target uses physical regs at Prolog/Epilog insertion /// time. If true (most machines), all vregs must be allocated before diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 6b52e97a..74724c2 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -345,7 +345,7 @@ void AsmPrinter::getNameWithPrefix(SmallVectorImpl &Name, } MCSymbol *AsmPrinter::getSymbol(const GlobalValue *GV) const { - return TM.getSymbol(GV, getObjFileLowering().getMangler()); + return TM.getSymbol(GV); } /// EmitGlobalVariable - Emit the specified global variable to the .s file. diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 539d485..bdb1210 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -55,9 +55,9 @@ MCSymbol *TargetLoweringObjectFileELF::getCFIPersonalitySymbol( unsigned Encoding = getPersonalityEncoding(); if ((Encoding & 0x80) == dwarf::DW_EH_PE_indirect) return getContext().getOrCreateSymbol(StringRef("DW.ref.") + - TM.getSymbol(GV, getMangler())->getName()); + TM.getSymbol(GV)->getName()); if ((Encoding & 0x70) == dwarf::DW_EH_PE_absptr) - return TM.getSymbol(GV, getMangler()); + return TM.getSymbol(GV); report_fatal_error("We do not support this DWARF encoding yet!"); } @@ -96,7 +96,7 @@ const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference( // gets emitted by the asmprinter. MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym); if (!StubSym.getPointer()) { - MCSymbol *Sym = TM.getSymbol(GV, getMangler()); + MCSymbol *Sym = TM.getSymbol(GV); StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); } @@ -443,10 +443,9 @@ const MCExpr *TargetLoweringObjectFileELF::lowerRelativeReference( return nullptr; return MCBinaryExpr::createSub( - MCSymbolRefExpr::create(TM.getSymbol(LHS, getMangler()), PLTRelativeVariantKind, + MCSymbolRefExpr::create(TM.getSymbol(LHS), PLTRelativeVariantKind, getContext()), - MCSymbolRefExpr::create(TM.getSymbol(RHS, getMangler()), getContext()), - getContext()); + MCSymbolRefExpr::create(TM.getSymbol(RHS), getContext()), getContext()); } void @@ -712,7 +711,7 @@ const MCExpr *TargetLoweringObjectFileMachO::getTTypeGlobalReference( // gets emitted by the asmprinter. MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym); if (!StubSym.getPointer()) { - MCSymbol *Sym = TM.getSymbol(GV, getMangler()); + MCSymbol *Sym = TM.getSymbol(GV); StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); } @@ -738,7 +737,7 @@ MCSymbol *TargetLoweringObjectFileMachO::getCFIPersonalitySymbol( // gets emitted by the asmprinter. MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym); if (!StubSym.getPointer()) { - MCSymbol *Sym = TM.getSymbol(GV, getMangler()); + MCSymbol *Sym = TM.getSymbol(GV); StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); } @@ -929,7 +928,7 @@ MCSection *TargetLoweringObjectFileCOFF::getExplicitSectionGlobal( ComdatGV = GO; if (!ComdatGV->hasPrivateLinkage()) { - MCSymbol *Sym = TM.getSymbol(ComdatGV, getMangler()); + MCSymbol *Sym = TM.getSymbol(ComdatGV); COMDATSymName = Sym->getName(); Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT; } else { @@ -982,7 +981,7 @@ MCSection *TargetLoweringObjectFileCOFF::SelectSectionForGlobal( UniqueID = NextUniqueID++; if (!ComdatGV->hasPrivateLinkage()) { - MCSymbol *Sym = TM.getSymbol(ComdatGV, getMangler()); + MCSymbol *Sym = TM.getSymbol(ComdatGV); StringRef COMDATSymName = Sym->getName(); return getContext().getCOFFSection(Name, Characteristics, Kind, COMDATSymName, Selection, UniqueID); @@ -1037,7 +1036,7 @@ MCSection *TargetLoweringObjectFileCOFF::getSectionForJumpTable( if (F.hasPrivateLinkage()) return ReadOnlySection; - MCSymbol *Sym = TM.getSymbol(&F, getMangler()); + MCSymbol *Sym = TM.getSymbol(&F); StringRef COMDATSymName = Sym->getName(); SectionKind Kind = SectionKind::getReadOnly(); diff --git a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp index cafbb53..8875f9b 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp @@ -37,7 +37,7 @@ const MCExpr *AArch64_MachoTargetObjectFile::getTTypeGlobalReference( // won't reference using the GOT, so we need this target-specific // version. if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) { - const MCSymbol *Sym = TM.getSymbol(GV, getMangler()); + const MCSymbol *Sym = TM.getSymbol(GV); const MCExpr *Res = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOT, getContext()); MCSymbol *PCSym = getContext().createTempSymbol(); @@ -53,7 +53,7 @@ const MCExpr *AArch64_MachoTargetObjectFile::getTTypeGlobalReference( MCSymbol *AArch64_MachoTargetObjectFile::getCFIPersonalitySymbol( const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const { - return TM.getSymbol(GV, getMangler()); + return TM.getSymbol(GV); } const MCExpr *AArch64_MachoTargetObjectFile::getIndirectSymViaGOTPCRel( diff --git a/llvm/lib/Target/ARM/ARMTargetObjectFile.cpp b/llvm/lib/Target/ARM/ARMTargetObjectFile.cpp index 8218a90..ec364e8 100644 --- a/llvm/lib/Target/ARM/ARMTargetObjectFile.cpp +++ b/llvm/lib/Target/ARM/ARMTargetObjectFile.cpp @@ -49,7 +49,7 @@ const MCExpr *ARMElfTargetObjectFile::getTTypeGlobalReference( assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only"); - return MCSymbolRefExpr::create(TM.getSymbol(GV, getMangler()), + return MCSymbolRefExpr::create(TM.getSymbol(GV), MCSymbolRefExpr::VK_ARM_TARGET2, getContext()); } diff --git a/llvm/lib/Target/Sparc/SparcTargetObjectFile.cpp b/llvm/lib/Target/Sparc/SparcTargetObjectFile.cpp index b3d7668..8fdde15 100644 --- a/llvm/lib/Target/Sparc/SparcTargetObjectFile.cpp +++ b/llvm/lib/Target/Sparc/SparcTargetObjectFile.cpp @@ -28,7 +28,7 @@ const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference( // gets emitted by the asmprinter. MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym); if (!StubSym.getPointer()) { - MCSymbol *Sym = TM.getSymbol(GV, getMangler()); + MCSymbol *Sym = TM.getSymbol(GV); StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); } diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp index a8b2af1..375f851 100644 --- a/llvm/lib/Target/TargetLoweringObjectFile.cpp +++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp @@ -118,7 +118,7 @@ MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase( MCSymbol *TargetLoweringObjectFile::getCFIPersonalitySymbol( const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const { - return TM.getSymbol(GV, *Mang); + return TM.getSymbol(GV); } void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer, @@ -288,7 +288,7 @@ const MCExpr *TargetLoweringObjectFile::getTTypeGlobalReference( const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const { const MCSymbolRefExpr *Ref = - MCSymbolRefExpr::create(TM.getSymbol(GV, *Mang), getContext()); + MCSymbolRefExpr::create(TM.getSymbol(GV), getContext()); return getTTypeReference(Ref, Encoding, Streamer); } diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index 792280a..e16ced1 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -213,9 +213,9 @@ void TargetMachine::getNameWithPrefix(SmallVectorImpl &Name, TLOF->getNameWithPrefix(Name, GV, *this); } -MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV, Mangler &Mang) const { - SmallString<128> NameStr; - getNameWithPrefix(NameStr, GV, Mang); +MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV) const { const TargetLoweringObjectFile *TLOF = getObjFileLowering(); + SmallString<128> NameStr; + getNameWithPrefix(NameStr, GV, TLOF->getMangler()); return TLOF->getContext().getOrCreateSymbol(NameStr); } diff --git a/llvm/lib/Target/X86/X86TargetObjectFile.cpp b/llvm/lib/Target/X86/X86TargetObjectFile.cpp index d050ec0..7f70829 100644 --- a/llvm/lib/Target/X86/X86TargetObjectFile.cpp +++ b/llvm/lib/Target/X86/X86TargetObjectFile.cpp @@ -30,7 +30,7 @@ const MCExpr *X86_64MachoTargetObjectFile::getTTypeGlobalReference( // On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which // is an indirect pc-relative reference. if ((Encoding & DW_EH_PE_indirect) && (Encoding & DW_EH_PE_pcrel)) { - const MCSymbol *Sym = TM.getSymbol(GV, getMangler()); + const MCSymbol *Sym = TM.getSymbol(GV); const MCExpr *Res = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext()); const MCExpr *Four = MCConstantExpr::create(4, getContext()); @@ -44,7 +44,7 @@ const MCExpr *X86_64MachoTargetObjectFile::getTTypeGlobalReference( MCSymbol *X86_64MachoTargetObjectFile::getCFIPersonalitySymbol( const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const { - return TM.getSymbol(GV, getMangler()); + return TM.getSymbol(GV); } const MCExpr *X86_64MachoTargetObjectFile::getIndirectSymViaGOTPCRel( @@ -108,7 +108,7 @@ const MCExpr *X86WindowsTargetObjectFile::lowerRelativeReference( cast(RHS)->hasInitializer() || RHS->hasSection()) return nullptr; - return MCSymbolRefExpr::create(TM.getSymbol(LHS, getMangler()), + return MCSymbolRefExpr::create(TM.getSymbol(LHS), MCSymbolRefExpr::VK_COFF_IMGREL32, getContext()); } -- 2.7.4