eliminate some uses of Mangler::makeNameProper.

llvm-svn: 93305
This commit is contained in:
Chris Lattner 2010-01-13 07:56:59 +00:00
parent ba8b3ed4f1
commit f2090cf7fd
3 changed files with 23 additions and 14 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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<MachineModuleInfoMachO>().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;
}
}