From ee9250bb4f88364511cfda9ae95ad787bff1a72c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 13 Jan 2010 07:56:59 +0000 Subject: [PATCH] eliminate some uses of Mangler::makeNameProper. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93305 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 13 ++++++----- lib/Target/TargetLoweringObjectFile.cpp | 2 +- lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp | 22 +++++++++++++------ 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index 6fff961c465..d71397d4606 100644 --- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -71,18 +71,19 @@ namespace { } void Init(StringRef GVName, Mangler *Mang) { - // Already initialized. - if (!Stub.empty()) return; + assert(!GVName.empty()); + if (!Stub.empty()) return; // Already initialized. + // Get the names for the external symbol name. SmallString<128> TmpStr; - Mang->makeNameProper(TmpStr, GVName + "$stub", Mangler::Private); + Mang->getNameWithPrefix(TmpStr, GVName + "$stub", Mangler::Private); Stub = TmpStr.str(); TmpStr.clear(); - Mang->makeNameProper(TmpStr, GVName + "$lazy_ptr", Mangler::Private); + Mang->getNameWithPrefix(TmpStr, GVName + "$lazy_ptr", Mangler::Private); LazyPtr = TmpStr.str(); TmpStr.clear(); - Mang->makeNameProper(TmpStr, GVName + "$stub$tmp", Mangler::Private); + Mang->getNameWithPrefix(TmpStr, GVName + "$stub$tmp", Mangler::Private); AnonSymbol = TmpStr.str(); } }; @@ -237,7 +238,7 @@ namespace { } if (MO.getType() == MachineOperand::MO_ExternalSymbol) { SmallString<128> MangledName; - Mang->makeNameProper(MangledName, MO.getSymbolName()); + Mang->getNameWithPrefix(MangledName, MO.getSymbolName()); FnStubInfo &FnInfo = FnStubs[MangledName.str()]; FnInfo.Init(MO.getSymbolName(), Mang); O << FnInfo.Stub; diff --git a/lib/Target/TargetLoweringObjectFile.cpp b/lib/Target/TargetLoweringObjectFile.cpp index 49e266c6d7f..bd683db8932 100644 --- a/lib/Target/TargetLoweringObjectFile.cpp +++ b/lib/Target/TargetLoweringObjectFile.cpp @@ -1080,7 +1080,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, if (GV->isWeakForLinker()) { const char *Prefix = getCOFFSectionPrefixForUniqueGlobal(Kind); SmallString<128> Name(Prefix, Prefix+strlen(Prefix)); - Mang->makeNameProper(Name, GV->getNameStr()); + Mang->getNameWithPrefix(Name, GV->getName()); return getCOFFSection(Name.str(), false, Kind); } diff --git a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp index 6058698ca0c..70c6dd03eb1 100644 --- a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp @@ -283,24 +283,32 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO) { break; } case MachineOperand::MO_ExternalSymbol: { - Mang->makeNameProper(TempNameStr, MO.getSymbolName()); + const MCSymbol *SymToPrint; if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) { - TempNameStr += "$stub"; - MCSymbol *Sym = OutContext.GetOrCreateSymbol(TempNameStr.str()); + Mang->getNameWithPrefix(TempNameStr, + StringRef(MO.getSymbolName())+"$stub"); + const MCSymbol *Sym = OutContext.GetOrCreateSymbol(TempNameStr.str()); const MCSymbol *&StubSym = MMI->getObjFileInfo().getFnStubEntry(Sym); if (StubSym == 0) { TempNameStr.erase(TempNameStr.end()-5, TempNameStr.end()); StubSym = OutContext.GetOrCreateSymbol(TempNameStr.str()); } + SymToPrint = StubSym; + } else { + Mang->getNameWithPrefix(TempNameStr, MO.getSymbolName()); + SymToPrint = OutContext.GetOrCreateSymbol(TempNameStr.str()); } // If the name begins with a dollar-sign, enclose it in parens. We do this // to avoid having it look like an integer immediate to the assembler. - if (TempNameStr[0] == '$') - O << '(' << TempNameStr << ')'; - else - O << TempNameStr; + if (SymToPrint->getName()[0] != '$') + SymToPrint->print(O, MAI); + else { + O << '('; + SymToPrint->print(O, MAI); + O << '('; + } break; } }