From 1816e314c62b0a472433fd04c814d870e2f5fe84 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 19 Oct 2009 18:44:38 +0000 Subject: [PATCH] switch hidden gv stubs to use MachineModuleInfoMachO instead of a custom map. llvm-svn: 84520 --- lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 35 ++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index 581677b001b..32a8f5e77fd 100644 --- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -63,10 +63,6 @@ namespace { /// MachineFunction. const MachineConstantPool *MCP; - /// HiddenGVNonLazyPtrs - Keeps the set of GlobalValues with hidden - /// visibility that require non-lazy-pointers for indirect access. - StringMap HiddenGVNonLazyPtrs; - public: explicit ARMAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, const MCAsmInfo *T, bool V) @@ -159,17 +155,26 @@ namespace { Name = Mang->getMangledName(GV); else { // FIXME: Remove this when Darwin transition to @GOT like syntax. - std::string SymName = Mang->getMangledName(GV); Name = Mang->getMangledName(GV, "$non_lazy_ptr", true); - if (GV->hasHiddenVisibility()) - HiddenGVNonLazyPtrs[SymName] = Name; - else { - MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name.c_str()); + MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name.c_str()); + + if (GV->hasHiddenVisibility()) { + const MCSymbol *&StubSym = + MMI->getObjFileInfo() + .getHiddenGVStubEntry(Sym); + if (StubSym == 0) { + //NameStr.clear(); + //Mang->getNameWithPrefix(NameStr, GV, false); + std::string SymName = Mang->getMangledName(GV); + StubSym = OutContext.GetOrCreateSymbol(SymName.c_str()); + } + } else { const MCSymbol *&StubSym = MMI->getObjFileInfo().getGVStubEntry(Sym); if (StubSym == 0) { //NameStr.clear(); //Mang->getNameWithPrefix(NameStr, GV, false); + std::string SymName = Mang->getMangledName(GV); StubSym = OutContext.GetOrCreateSymbol(SymName.c_str()); } } @@ -1265,13 +1270,15 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) { } } - if (!HiddenGVNonLazyPtrs.empty()) { + Stubs = MMIMacho.GetHiddenGVStubList(); + if (!Stubs.empty()) { OutStreamer.SwitchSection(getObjFileLowering().getDataSection()); EmitAlignment(2); - for (StringMap::iterator I = HiddenGVNonLazyPtrs.begin(), - E = HiddenGVNonLazyPtrs.end(); I != E; ++I) { - O << I->second << ":\n"; - O << "\t.long " << I->getKeyData() << "\n"; + for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { + Stubs[i].first->print(O, MAI); + O << ":\n\t.long "; + Stubs[i].second->print(O, MAI); + O << "\n"; } }