Move getSymbolWithGlobalValueBase to TargetLoweringObjectFile.

This allows it to be used in TargetLoweringObjectFileImpl.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196117 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2013-12-02 16:25:47 +00:00
parent 4f9dd99c28
commit cce5873de3
8 changed files with 27 additions and 27 deletions

View File

@ -306,7 +306,7 @@ namespace llvm {
/// Return the MCSymbol for a private symbol with global value name as its /// Return the MCSymbol for a private symbol with global value name as its
/// base, with the specified suffix. /// base, with the specified suffix.
MCSymbol *GetSymbolWithGlobalValueBase(const GlobalValue *GV, MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV,
StringRef Suffix) const; StringRef Suffix) const;
/// GetExternalSymbolSymbol - Return the MCSymbol for the specified /// GetExternalSymbolSymbol - Return the MCSymbol for the specified

View File

@ -121,6 +121,11 @@ public:
/// main label that is the address of the global /// main label that is the address of the global
MCSymbol *getSymbol(Mangler &M, const GlobalValue *GV) const; MCSymbol *getSymbol(Mangler &M, const GlobalValue *GV) const;
/// Return the MCSymbol for a private symbol with global value name as its
/// base, with the specified suffix.
MCSymbol *getSymbolWithGlobalValueBase(Mangler &M, const GlobalValue *GV,
StringRef Suffix) const;
// getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality. // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
virtual MCSymbol * virtual MCSymbol *
getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,

View File

@ -2033,12 +2033,9 @@ MCSymbol *AsmPrinter::GetJTSetSymbol(unsigned UID, unsigned MBBID) const {
Twine(UID) + "_set_" + Twine(MBBID)); Twine(UID) + "_set_" + Twine(MBBID));
} }
MCSymbol *AsmPrinter::GetSymbolWithGlobalValueBase(const GlobalValue *GV, MCSymbol *AsmPrinter::getSymbolWithGlobalValueBase(const GlobalValue *GV,
StringRef Suffix) const { StringRef Suffix) const {
SmallString<60> NameStr; return getObjFileLowering().getSymbolWithGlobalValueBase(*Mang, GV, Suffix);
Mang->getNameWithPrefix(NameStr, GV, true);
NameStr.append(Suffix.begin(), Suffix.end());
return OutContext.GetOrCreateSymbol(NameStr.str());
} }
/// GetExternalSymbolSymbol - Return the MCSymbol for the specified /// GetExternalSymbolSymbol - Return the MCSymbol for the specified

View File

@ -95,13 +95,10 @@ getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
if (Encoding & dwarf::DW_EH_PE_indirect) { if (Encoding & dwarf::DW_EH_PE_indirect) {
MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>(); MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>();
SmallString<128> Name; MCSymbol *SSym = getSymbolWithGlobalValueBase(*Mang, GV, ".DW.stub");
Mang->getNameWithPrefix(Name, GV, true);
Name += ".DW.stub";
// Add information about the stub reference to ELFMMI so that the stub // Add information about the stub reference to ELFMMI so that the stub
// gets emitted by the asmprinter. // gets emitted by the asmprinter.
MCSymbol *SSym = getContext().GetOrCreateSymbol(Name.str());
MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym); MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
if (StubSym.getPointer() == 0) { if (StubSym.getPointer() == 0) {
MCSymbol *Sym = getSymbol(*Mang, GV); MCSymbol *Sym = getSymbol(*Mang, GV);
@ -632,13 +629,10 @@ getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
MachineModuleInfoMachO &MachOMMI = MachineModuleInfoMachO &MachOMMI =
MMI->getObjFileInfo<MachineModuleInfoMachO>(); MMI->getObjFileInfo<MachineModuleInfoMachO>();
SmallString<128> Name; MCSymbol *SSym = getSymbolWithGlobalValueBase(*Mang, GV, "$non_lazy_ptr");
Mang->getNameWithPrefix(Name, GV, true);
Name += "$non_lazy_ptr";
// Add information about the stub reference to MachOMMI so that the stub // Add information about the stub reference to MachOMMI so that the stub
// gets emitted by the asmprinter. // gets emitted by the asmprinter.
MCSymbol *SSym = getContext().GetOrCreateSymbol(Name.str());
MachineModuleInfoImpl::StubValueTy &StubSym = MachineModuleInfoImpl::StubValueTy &StubSym =
GV->hasHiddenVisibility() ? MachOMMI.getHiddenGVStubEntry(SSym) : GV->hasHiddenVisibility() ? MachOMMI.getHiddenGVStubEntry(SSym) :
MachOMMI.getGVStubEntry(SSym); MachOMMI.getGVStubEntry(SSym);
@ -663,13 +657,10 @@ getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
MachineModuleInfoMachO &MachOMMI = MachineModuleInfoMachO &MachOMMI =
MMI->getObjFileInfo<MachineModuleInfoMachO>(); MMI->getObjFileInfo<MachineModuleInfoMachO>();
SmallString<128> Name; MCSymbol *SSym = getSymbolWithGlobalValueBase(*Mang, GV, "$non_lazy_ptr");
Mang->getNameWithPrefix(Name, GV, true);
Name += "$non_lazy_ptr";
// Add information about the stub reference to MachOMMI so that the stub // Add information about the stub reference to MachOMMI so that the stub
// gets emitted by the asmprinter. // gets emitted by the asmprinter.
MCSymbol *SSym = getContext().GetOrCreateSymbol(Name.str());
MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym); MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym);
if (StubSym.getPointer() == 0) { if (StubSym.getPointer() == 0) {
MCSymbol *Sym = getSymbol(*Mang, GV); MCSymbol *Sym = getSymbol(*Mang, GV);

View File

@ -774,7 +774,7 @@ MCSymbol *ARMAsmPrinter::GetARMGVSymbol(const GlobalValue *GV,
return getSymbol(GV); return getSymbol(GV);
// FIXME: Remove this when Darwin transition to @GOT like syntax. // FIXME: Remove this when Darwin transition to @GOT like syntax.
MCSymbol *MCSym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); MCSymbol *MCSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
MachineModuleInfoMachO &MMIMachO = MachineModuleInfoMachO &MMIMachO =
MMI->getObjFileInfo<MachineModuleInfoMachO>(); MMI->getObjFileInfo<MachineModuleInfoMachO>();
MachineModuleInfoImpl::StubValueTy &StubSym = MachineModuleInfoImpl::StubValueTy &StubSym =

View File

@ -173,7 +173,7 @@ void PPCAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
if (TM.getRelocationModel() != Reloc::Static && if (TM.getRelocationModel() != Reloc::Static &&
(GV->isDeclaration() || GV->isWeakForLinker())) { (GV->isDeclaration() || GV->isWeakForLinker())) {
if (!GV->hasHiddenVisibility()) { if (!GV->hasHiddenVisibility()) {
SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); SymToPrint = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
MachineModuleInfoImpl::StubValueTy &StubSym = MachineModuleInfoImpl::StubValueTy &StubSym =
MMI->getObjFileInfo<MachineModuleInfoMachO>() MMI->getObjFileInfo<MachineModuleInfoMachO>()
.getGVStubEntry(SymToPrint); .getGVStubEntry(SymToPrint);
@ -182,7 +182,7 @@ void PPCAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
StubValueTy(getSymbol(GV), !GV->hasInternalLinkage()); StubValueTy(getSymbol(GV), !GV->hasInternalLinkage());
} else if (GV->isDeclaration() || GV->hasCommonLinkage() || } else if (GV->isDeclaration() || GV->hasCommonLinkage() ||
GV->hasAvailableExternallyLinkage()) { GV->hasAvailableExternallyLinkage()) {
SymToPrint = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); SymToPrint = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
MachineModuleInfoImpl::StubValueTy &StubSym = MachineModuleInfoImpl::StubValueTy &StubSym =
MMI->getObjFileInfo<MachineModuleInfoMachO>(). MMI->getObjFileInfo<MachineModuleInfoMachO>().
@ -1034,7 +1034,7 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
for (std::vector<const Function*>::const_iterator I = Personalities.begin(), for (std::vector<const Function*>::const_iterator I = Personalities.begin(),
E = Personalities.end(); I != E; ++I) { E = Personalities.end(); I != E; ++I) {
if (*I) { if (*I) {
MCSymbol *NLPSym = GetSymbolWithGlobalValueBase(*I, "$non_lazy_ptr"); MCSymbol *NLPSym = getSymbolWithGlobalValueBase(*I, "$non_lazy_ptr");
MachineModuleInfoImpl::StubValueTy &StubSym = MachineModuleInfoImpl::StubValueTy &StubSym =
MMIMacho.getGVStubEntry(NLPSym); MMIMacho.getGVStubEntry(NLPSym);
StubSym = MachineModuleInfoImpl::StubValueTy(getSymbol(*I), true); StubSym = MachineModuleInfoImpl::StubValueTy(getSymbol(*I), true);

View File

@ -106,6 +106,13 @@ MCSymbol *TargetLoweringObjectFile::getSymbol(Mangler &M,
return Ctx->GetOrCreateSymbol(NameStr.str()); return Ctx->GetOrCreateSymbol(NameStr.str());
} }
MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase(
Mangler &M, const GlobalValue *GV, StringRef Suffix) const {
SmallString<60> NameStr;
M.getNameWithPrefix(NameStr, GV, true);
NameStr.append(Suffix.begin(), Suffix.end());
return Ctx->GetOrCreateSymbol(NameStr.str());
}
MCSymbol *TargetLoweringObjectFile:: MCSymbol *TargetLoweringObjectFile::
getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,

View File

@ -87,11 +87,11 @@ static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO,
MCSymbol *GVSym; MCSymbol *GVSym;
if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
GVSym = P.GetSymbolWithGlobalValueBase(GV, "$stub"); GVSym = P.getSymbolWithGlobalValueBase(GV, "$stub");
else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY || else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE || MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE) MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
GVSym = P.GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); GVSym = P.getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
else else
GVSym = P.getSymbol(GV); GVSym = P.getSymbol(GV);
@ -102,14 +102,14 @@ static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO,
if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY || if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) { MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
MCSymbol *Sym = P.GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); MCSymbol *Sym = P.getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
MachineModuleInfoImpl::StubValueTy &StubSym = MachineModuleInfoImpl::StubValueTy &StubSym =
P.MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym); P.MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
if (StubSym.getPointer() == 0) if (StubSym.getPointer() == 0)
StubSym = MachineModuleInfoImpl:: StubSym = MachineModuleInfoImpl::
StubValueTy(P.getSymbol(GV), !GV->hasInternalLinkage()); StubValueTy(P.getSymbol(GV), !GV->hasInternalLinkage());
} else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){ } else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){
MCSymbol *Sym = P.GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr"); MCSymbol *Sym = P.getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
MachineModuleInfoImpl::StubValueTy &StubSym = MachineModuleInfoImpl::StubValueTy &StubSym =
P.MMI->getObjFileInfo<MachineModuleInfoMachO>().getHiddenGVStubEntry( P.MMI->getObjFileInfo<MachineModuleInfoMachO>().getHiddenGVStubEntry(
Sym); Sym);
@ -117,7 +117,7 @@ static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO,
StubSym = MachineModuleInfoImpl:: StubSym = MachineModuleInfoImpl::
StubValueTy(P.getSymbol(GV), !GV->hasInternalLinkage()); StubValueTy(P.getSymbol(GV), !GV->hasInternalLinkage());
} else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) { } else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
MCSymbol *Sym = P.GetSymbolWithGlobalValueBase(GV, "$stub"); MCSymbol *Sym = P.getSymbolWithGlobalValueBase(GV, "$stub");
MachineModuleInfoImpl::StubValueTy &StubSym = MachineModuleInfoImpl::StubValueTy &StubSym =
P.MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym); P.MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
if (StubSym.getPointer() == 0) if (StubSym.getPointer() == 0)