From 67e71746b1a96204a9f43688df0115f6fc731bfe Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 11 Sep 2009 07:03:20 +0000 Subject: [PATCH] switch HiddenGVStubs to be a DenseMap instead of a string map, mirroring FnStubs and GVStubs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81514 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | 22 +++++++++++++++++----- lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h | 4 ++-- lib/Target/X86/AsmPrinter/X86MCInstLower.cpp | 11 +++++++++-- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index 83ffdb8949..418e7d9d63 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -330,7 +330,16 @@ void X86ATTAsmPrinter::printSymbolOperand(const MachineOperand &MO) { StubSym = OutContext.GetOrCreateSymbol(NameStr.str()); } } else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){ - HiddenGVStubs[Name] = Mang->getMangledName(GV); + SmallString<128> NameStr; + Mang->getNameWithPrefix(NameStr, GV, true); + NameStr += "$non_lazy_ptr"; + MCSymbol *Sym = OutContext.GetOrCreateSymbol(NameStr.str()); + MCSymbol *&StubSym = HiddenGVStubs[Sym]; + if (StubSym == 0) { + NameStr.clear(); + Mang->getNameWithPrefix(NameStr, GV, false); + StubSym = OutContext.GetOrCreateSymbol(NameStr.str()); + } } else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) { SmallString<128> NameStr; Mang->getNameWithPrefix(NameStr, GV, true); @@ -949,10 +958,13 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) { if (!HiddenGVStubs.empty()) { OutStreamer.SwitchSection(getObjFileLowering().getDataSection()); EmitAlignment(2); - for (StringMap::iterator I = HiddenGVStubs.begin(), - E = HiddenGVStubs.end(); I != E; ++I) - O << I->getKeyData() << ":\n" << MAI->getData32bitsDirective() - << I->second << '\n'; + for (DenseMap::iterator I = HiddenGVStubs.begin(), + E = HiddenGVStubs.end(); I != E; ++I) { + I->first->print(O, MAI); + O << ":\n" << MAI->getData32bitsDirective(); + I->second->print(O, MAI); + O << '\n'; + } } // Funny Darwin hack: This flag tells the linker that no global symbols diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h index 3545dce25f..8c534f67c8 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h @@ -215,10 +215,10 @@ class VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter { void emitFunctionHeader(const MachineFunction &MF); - // Necessary for Darwin to print out the apprioriate types of linker stubs - StringMap HiddenGVStubs; + // Necessary for Darwin to print out the appropriate types of linker stubs. DenseMap FnStubs; // Darwin $stub stubs. DenseMap GVStubs; // Darwin $non_lazy_ptr stub. + DenseMap HiddenGVStubs; // Darwin $non_lazy_ptr stub. // Necessary for dllexport support StringSet<> CygMingStubs, DLLExportedFns, DLLExportedGVs; diff --git a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp index 9f135fb37a..3cdb83f652 100644 --- a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp +++ b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp @@ -82,10 +82,17 @@ MCSymbol *X86ATTAsmPrinter::GetGlobalAddressSymbol(const MachineOperand &MO) { return Sym; } - case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: + case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: { Name += "$non_lazy_ptr"; - HiddenGVStubs[Name.str()] = StringRef(Name.data(), Name.size()-13); + MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name.str()); + MCSymbol *&StubSym = HiddenGVStubs[Sym]; + if (StubSym == 0) { + Name.clear(); + Mang->getNameWithPrefix(Name, GV, false); + StubSym = OutContext.GetOrCreateSymbol(Name.str()); + } break; + } case X86II::MO_DARWIN_STUB: { Name += "$stub"; MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name.str()); -- 2.11.4.GIT