llvm.org GIT mirror llvm / bc347f2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287645 91177308-0d34-0410-b5e6-96231b3b80d8 Tim Northover 3 years ago
9 changed file(s) with 24 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
260260
261261 void getNameWithPrefix(SmallVectorImpl &Name, const GlobalValue *GV,
262262 Mangler &Mang, bool MayAlwaysUsePrivate = false) const;
263 MCSymbol *getSymbol(const GlobalValue *GV, Mangler &Mang) const;
263 MCSymbol *getSymbol(const GlobalValue *GV) const;
264264
265265 /// True if the target uses physical regs at Prolog/Epilog insertion
266266 /// time. If true (most machines), all vregs must be allocated before
344344 }
345345
346346 MCSymbol *AsmPrinter::getSymbol(const GlobalValue *GV) const {
347 return TM.getSymbol(GV, getObjFileLowering().getMangler());
347 return TM.getSymbol(GV);
348348 }
349349
350350 /// EmitGlobalVariable - Emit the specified global variable to the .s file.
5454 unsigned Encoding = getPersonalityEncoding();
5555 if ((Encoding & 0x80) == dwarf::DW_EH_PE_indirect)
5656 return getContext().getOrCreateSymbol(StringRef("DW.ref.") +
57 TM.getSymbol(GV, getMangler())->getName());
57 TM.getSymbol(GV)->getName());
5858 if ((Encoding & 0x70) == dwarf::DW_EH_PE_absptr)
59 return TM.getSymbol(GV, getMangler());
59 return TM.getSymbol(GV);
6060 report_fatal_error("We do not support this DWARF encoding yet!");
6161 }
6262
9595 // gets emitted by the asmprinter.
9696 MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
9797 if (!StubSym.getPointer()) {
98 MCSymbol *Sym = TM.getSymbol(GV, getMangler());
98 MCSymbol *Sym = TM.getSymbol(GV);
9999 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
100100 }
101101
442442 return nullptr;
443443
444444 return MCBinaryExpr::createSub(
445 MCSymbolRefExpr::create(TM.getSymbol(LHS, getMangler()), PLTRelativeVariantKind,
445 MCSymbolRefExpr::create(TM.getSymbol(LHS), PLTRelativeVariantKind,
446446 getContext()),
447 MCSymbolRefExpr::create(TM.getSymbol(RHS, getMangler()), getContext()),
448 getContext());
447 MCSymbolRefExpr::create(TM.getSymbol(RHS), getContext()), getContext());
449448 }
450449
451450 void
711710 // gets emitted by the asmprinter.
712711 MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym);
713712 if (!StubSym.getPointer()) {
714 MCSymbol *Sym = TM.getSymbol(GV, getMangler());
713 MCSymbol *Sym = TM.getSymbol(GV);
715714 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
716715 }
717716
737736 // gets emitted by the asmprinter.
738737 MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym);
739738 if (!StubSym.getPointer()) {
740 MCSymbol *Sym = TM.getSymbol(GV, getMangler());
739 MCSymbol *Sym = TM.getSymbol(GV);
741740 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
742741 }
743742
928927 ComdatGV = GO;
929928
930929 if (!ComdatGV->hasPrivateLinkage()) {
931 MCSymbol *Sym = TM.getSymbol(ComdatGV, getMangler());
930 MCSymbol *Sym = TM.getSymbol(ComdatGV);
932931 COMDATSymName = Sym->getName();
933932 Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
934933 } else {
981980 UniqueID = NextUniqueID++;
982981
983982 if (!ComdatGV->hasPrivateLinkage()) {
984 MCSymbol *Sym = TM.getSymbol(ComdatGV, getMangler());
983 MCSymbol *Sym = TM.getSymbol(ComdatGV);
985984 StringRef COMDATSymName = Sym->getName();
986985 return getContext().getCOFFSection(Name, Characteristics, Kind,
987986 COMDATSymName, Selection, UniqueID);
10361035 if (F.hasPrivateLinkage())
10371036 return ReadOnlySection;
10381037
1039 MCSymbol *Sym = TM.getSymbol(&F, getMangler());
1038 MCSymbol *Sym = TM.getSymbol(&F);
10401039 StringRef COMDATSymName = Sym->getName();
10411040
10421041 SectionKind Kind = SectionKind::getReadOnly();
3636 // won't reference using the GOT, so we need this target-specific
3737 // version.
3838 if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
39 const MCSymbol *Sym = TM.getSymbol(GV, getMangler());
39 const MCSymbol *Sym = TM.getSymbol(GV);
4040 const MCExpr *Res =
4141 MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOT, getContext());
4242 MCSymbol *PCSym = getContext().createTempSymbol();
5252 MCSymbol *AArch64_MachoTargetObjectFile::getCFIPersonalitySymbol(
5353 const GlobalValue *GV, const TargetMachine &TM,
5454 MachineModuleInfo *MMI) const {
55 return TM.getSymbol(GV, getMangler());
55 return TM.getSymbol(GV);
5656 }
5757
5858 const MCExpr *AArch64_MachoTargetObjectFile::getIndirectSymViaGOTPCRel(
4848
4949 assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only");
5050
51 return MCSymbolRefExpr::create(TM.getSymbol(GV, getMangler()),
51 return MCSymbolRefExpr::create(TM.getSymbol(GV),
5252 MCSymbolRefExpr::VK_ARM_TARGET2, getContext());
5353 }
5454
2727 // gets emitted by the asmprinter.
2828 MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
2929 if (!StubSym.getPointer()) {
30 MCSymbol *Sym = TM.getSymbol(GV, getMangler());
30 MCSymbol *Sym = TM.getSymbol(GV);
3131 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
3232 }
3333
117117 MCSymbol *TargetLoweringObjectFile::getCFIPersonalitySymbol(
118118 const GlobalValue *GV, const TargetMachine &TM,
119119 MachineModuleInfo *MMI) const {
120 return TM.getSymbol(GV, *Mang);
120 return TM.getSymbol(GV);
121121 }
122122
123123 void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
287287 const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
288288 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
289289 const MCSymbolRefExpr *Ref =
290 MCSymbolRefExpr::create(TM.getSymbol(GV, *Mang), getContext());
290 MCSymbolRefExpr::create(TM.getSymbol(GV), getContext());
291291
292292 return getTTypeReference(Ref, Encoding, Streamer);
293293 }
212212 TLOF->getNameWithPrefix(Name, GV, *this);
213213 }
214214
215 MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV, Mangler &Mang) const {
215 MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV) const {
216 const TargetLoweringObjectFile *TLOF = getObjFileLowering();
216217 SmallString<128> NameStr;
217 getNameWithPrefix(NameStr, GV, Mang);
218 const TargetLoweringObjectFile *TLOF = getObjFileLowering();
218 getNameWithPrefix(NameStr, GV, TLOF->getMangler());
219219 return TLOF->getContext().getOrCreateSymbol(NameStr);
220220 }
2929 // On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
3030 // is an indirect pc-relative reference.
3131 if ((Encoding & DW_EH_PE_indirect) && (Encoding & DW_EH_PE_pcrel)) {
32 const MCSymbol *Sym = TM.getSymbol(GV, getMangler());
32 const MCSymbol *Sym = TM.getSymbol(GV);
3333 const MCExpr *Res =
3434 MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext());
3535 const MCExpr *Four = MCConstantExpr::create(4, getContext());
4343 MCSymbol *X86_64MachoTargetObjectFile::getCFIPersonalitySymbol(
4444 const GlobalValue *GV, const TargetMachine &TM,
4545 MachineModuleInfo *MMI) const {
46 return TM.getSymbol(GV, getMangler());
46 return TM.getSymbol(GV);
4747 }
4848
4949 const MCExpr *X86_64MachoTargetObjectFile::getIndirectSymViaGOTPCRel(
107107 cast(RHS)->hasInitializer() || RHS->hasSection())
108108 return nullptr;
109109
110 return MCSymbolRefExpr::create(TM.getSymbol(LHS, getMangler()),
110 return MCSymbolRefExpr::create(TM.getSymbol(LHS),
111111 MCSymbolRefExpr::VK_COFF_IMGREL32,
112112 getContext());
113113 }