simplify some code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93619 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-16 01:45:47 +00:00
parent d58e9cb42d
commit 76a3c48e68

View File

@ -65,14 +65,14 @@ namespace {
Stub = LazyPtr = AnonSymbol = 0; Stub = LazyPtr = AnonSymbol = 0;
} }
void Init(const GlobalValue *GV, Mangler *Mang, MCContext &Ctx) { void Init(const GlobalValue *GV, AsmPrinter *Printer) {
// Already initialized. // Already initialized.
if (Stub != 0) return; if (Stub != 0) return;
// Get the names. // Get the names.
SmallString<128> TmpStr; Stub = Printer->GetPrivateGlobalValueSymbolStub(GV, "$stub");
Mang->getNameWithPrefix(TmpStr, GV, true); LazyPtr = Printer->GetPrivateGlobalValueSymbolStub(GV, "$lazy_ptr");
MakeSymbols(TmpStr, Ctx); AnonSymbol = Printer->GetPrivateGlobalValueSymbolStub(GV, "$stub$tmp");
} }
void Init(StringRef GVName, Mangler *Mang, MCContext &Ctx) { void Init(StringRef GVName, Mangler *Mang, MCContext &Ctx) {
@ -81,10 +81,6 @@ namespace {
// Get the names for the external symbol name. // Get the names for the external symbol name.
SmallString<128> TmpStr; SmallString<128> TmpStr;
Mang->getNameWithPrefix(TmpStr, GVName, Mangler::Private); Mang->getNameWithPrefix(TmpStr, GVName, Mangler::Private);
MakeSymbols(TmpStr, Ctx);
}
void MakeSymbols(SmallString<128> &TmpStr, MCContext &Ctx) {
TmpStr += "$stub"; TmpStr += "$stub";
Stub = Ctx.GetOrCreateSymbol(TmpStr.str()); Stub = Ctx.GetOrCreateSymbol(TmpStr.str());
TmpStr.erase(TmpStr.end()-5, TmpStr.end()); // Remove $stub TmpStr.erase(TmpStr.end()-5, TmpStr.end()); // Remove $stub
@ -241,7 +237,7 @@ namespace {
if (GV->isDeclaration() || GV->isWeakForLinker()) { if (GV->isDeclaration() || GV->isWeakForLinker()) {
// Dynamically-resolved functions need a stub for the function. // Dynamically-resolved functions need a stub for the function.
FnStubInfo &FnInfo = FnStubs[Mang->getMangledName(GV)]; FnStubInfo &FnInfo = FnStubs[Mang->getMangledName(GV)];
FnInfo.Init(GV, Mang, OutContext); FnInfo.Init(GV, this);
FnInfo.Stub->print(O, MAI); FnInfo.Stub->print(O, MAI);
return; return;
} }