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
This commit is contained in:
Chris Lattner 2009-09-11 07:03:20 +00:00
parent 46091d70f5
commit 9e6ffba26b
3 changed files with 28 additions and 9 deletions

View File

@ -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<std::string>::iterator I = HiddenGVStubs.begin(),
E = HiddenGVStubs.end(); I != E; ++I)
O << I->getKeyData() << ":\n" << MAI->getData32bitsDirective()
<< I->second << '\n';
for (DenseMap<MCSymbol*, MCSymbol*>::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

View File

@ -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<std::string> HiddenGVStubs;
// Necessary for Darwin to print out the appropriate types of linker stubs.
DenseMap<MCSymbol*, MCSymbol*> FnStubs; // Darwin $stub stubs.
DenseMap<MCSymbol*, MCSymbol*> GVStubs; // Darwin $non_lazy_ptr stub.
DenseMap<MCSymbol*, MCSymbol*> HiddenGVStubs; // Darwin $non_lazy_ptr stub.
// Necessary for dllexport support
StringSet<> CygMingStubs, DLLExportedFns, DLLExportedGVs;

View File

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