[llvm-commits] [llvm] r81513 - in /llvm/trunk/lib/Target/X86/AsmPrinter: X86ATTAsmPrinter.cpp X86ATTAsmPrinter.h X86MCInstLower.cpp
Chris Lattner
sabre at nondot.org
Thu Sep 10 23:59:18 PDT 2009
Author: lattner
Date: Fri Sep 11 01:59:18 2009
New Revision: 81513
URL: http://llvm.org/viewvc/llvm-project?rev=81513&view=rev
Log:
Fix a bug I introduced in FnStubs generation, switch GVStubs to be a
densemap instead of StringMap to match FnStubs.
Modified:
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=81513&r1=81512&r2=81513&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Fri Sep 11 01:59:18 2009
@@ -318,12 +318,30 @@
Name = "__imp_" + Name;
if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
- MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE)
- GVStubs[Name] = Mang->getMangledName(GV);
- else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
+ MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
+ SmallString<128> NameStr;
+ Mang->getNameWithPrefix(NameStr, GV, true);
+ NameStr += "$non_lazy_ptr";
+ MCSymbol *Sym = OutContext.GetOrCreateSymbol(NameStr.str());
+ MCSymbol *&StubSym = GVStubs[Sym];
+ if (StubSym == 0) {
+ NameStr.clear();
+ Mang->getNameWithPrefix(NameStr, GV, false);
+ StubSym = OutContext.GetOrCreateSymbol(NameStr.str());
+ }
+ } else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){
HiddenGVStubs[Name] = Mang->getMangledName(GV);
- else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
- FnStubs.insert(OutContext.GetOrCreateSymbol(Name));
+ } else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
+ SmallString<128> NameStr;
+ Mang->getNameWithPrefix(NameStr, GV, true);
+ NameStr += "$stub";
+ MCSymbol *Sym = OutContext.GetOrCreateSymbol(NameStr.str());
+ MCSymbol *&StubSym = FnStubs[Sym];
+ if (StubSym == 0) {
+ NameStr.clear();
+ Mang->getNameWithPrefix(NameStr, GV, false);
+ StubSym = OutContext.GetOrCreateSymbol(NameStr.str());
+ }
}
// If the name begins with a dollar-sign, enclose it in parens. We do this
@@ -340,7 +358,11 @@
std::string Name = Mang->makeNameProper(MO.getSymbolName());
if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
Name += "$stub";
- FnStubs.insert(OutContext.GetOrCreateSymbol(Name));
+ MCSymbol *&StubSym = FnStubs[OutContext.GetOrCreateSymbol(Name)];
+ if (StubSym == 0) {
+ Name.erase(Name.end()-5, Name.end());
+ StubSym = OutContext.GetOrCreateSymbol(Name);
+ }
}
// If the name begins with a dollar-sign, enclose it in parens. We do this
@@ -868,10 +890,21 @@
if (MAI->doesSupportExceptionHandling() && MMI && !Subtarget->is64Bit()) {
const std::vector<Function*> &Personalities = MMI->getPersonalities();
for (unsigned i = 0, e = Personalities.size(); i != e; ++i) {
- if (Personalities[i])
- GVStubs[Mang->getMangledName(Personalities[i], "$non_lazy_ptr",
- true /*private label*/)] =
- Mang->getMangledName(Personalities[i]);
+ if (Personalities[i] == 0)
+ continue;
+
+ SmallString<128> Name;
+ Mang->getNameWithPrefix(Name, Personalities[i], true /*private label*/);
+ Name += "$non_lazy_ptr";
+ MCSymbol *NLPName = OutContext.GetOrCreateSymbol(Name.str());
+
+ MCSymbol *&StubName = GVStubs[NLPName];
+ if (StubName != 0) continue;
+
+
+ Name.clear();
+ Mang->getNameWithPrefix(Name, Personalities[i], false);
+ StubName = OutContext.GetOrCreateSymbol(Name.str());
}
}
@@ -885,17 +918,12 @@
5, SectionKind::getMetadata());
OutStreamer.SwitchSection(TheSection);
// FIXME: This iteration order is unstable!!
- for (SmallPtrSet<MCSymbol*, 16>::iterator I = FnStubs.begin(),
+ for (DenseMap<MCSymbol*, MCSymbol*>::iterator I = FnStubs.begin(),
E = FnStubs.end(); I != E; ++I) {
- MCSymbol *Sym = *I;
- Sym->print(O, MAI);
-
+ I->first->print(O, MAI);
O << ":\n" << "\t.indirect_symbol ";
-
// Get the MCSymbol without the $stub suffix.
- Sym = OutContext.GetOrCreateSymbol(StringRef(Sym->getName()).substr(0,
- Sym->getName().size()-5));
- Sym->print(O, MAI);
+ I->second->print(O, MAI);
O << "\n\thlt ; hlt ; hlt ; hlt ; hlt\n";
}
O << '\n';
@@ -908,10 +936,14 @@
MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS,
SectionKind::getMetadata());
OutStreamer.SwitchSection(TheSection);
- for (StringMap<std::string>::iterator I = GVStubs.begin(),
- E = GVStubs.end(); I != E; ++I)
- O << I->getKeyData() << ":\n\t.indirect_symbol "
- << I->second << "\n\t.long\t0\n";
+ // FIXME: This iteration order is unstable!!
+ for (DenseMap<MCSymbol*, MCSymbol*>::iterator I = GVStubs.begin(),
+ E = GVStubs.end(); I != E; ++I) {
+ I->first->print(O, MAI);
+ O << ":\n\t.indirect_symbol ";
+ I->second->print(O, MAI);
+ O << "\n\t.long\t0\n";
+ }
}
if (!HiddenGVStubs.empty()) {
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h?rev=81513&r1=81512&r2=81513&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Fri Sep 11 01:59:18 2009
@@ -216,8 +216,9 @@
void emitFunctionHeader(const MachineFunction &MF);
// Necessary for Darwin to print out the apprioriate types of linker stubs
- StringMap<std::string> GVStubs, HiddenGVStubs;
- SmallPtrSet<MCSymbol*, 16> FnStubs; // Darwin $stub stubs.
+ StringMap<std::string> HiddenGVStubs;
+ DenseMap<MCSymbol*, MCSymbol*> FnStubs; // Darwin $stub stubs.
+ DenseMap<MCSymbol*, MCSymbol*> GVStubs; // Darwin $non_lazy_ptr stub.
// Necessary for dllexport support
StringSet<> CygMingStubs, DLLExportedFns, DLLExportedGVs;
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=81513&r1=81512&r2=81513&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Fri Sep 11 01:59:18 2009
@@ -70,10 +70,18 @@
break;
}
case X86II::MO_DARWIN_NONLAZY:
- case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
+ case X86II::MO_DARWIN_NONLAZY_PIC_BASE: {
Name += "$non_lazy_ptr";
- GVStubs[Name.str()] = StringRef(Name.data(), Name.size()-13);
- break;
+ MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name.str());
+ MCSymbol *&StubSym = GVStubs[Sym];
+ if (StubSym == 0) {
+ Name.clear();
+ Mang->getNameWithPrefix(Name, GV, false);
+ StubSym = OutContext.GetOrCreateSymbol(Name.str());
+ }
+ return Sym;
+
+ }
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
Name += "$non_lazy_ptr";
HiddenGVStubs[Name.str()] = StringRef(Name.data(), Name.size()-13);
@@ -81,7 +89,12 @@
case X86II::MO_DARWIN_STUB: {
Name += "$stub";
MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name.str());
- FnStubs.insert(Sym);
+ MCSymbol *&StubSym = FnStubs[Sym];
+ if (StubSym == 0) {
+ Name.clear();
+ Mang->getNameWithPrefix(Name, GV, false);
+ StubSym = OutContext.GetOrCreateSymbol(Name.str());
+ }
return Sym;
}
// FIXME: These probably should be a modifier on the symbol or something??
@@ -119,7 +132,11 @@
case X86II::MO_DARWIN_STUB: {
Name += "$stub";
MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name.str());
- FnStubs.insert(Sym);
+ MCSymbol *&StubSym = FnStubs[Sym];
+ if (StubSym == 0) {
+ Name.erase(Name.end()-5, Name.end());
+ StubSym = OutContext.GetOrCreateSymbol(Name.str());
+ }
return Sym;
}
// FIXME: These probably should be a modifier on the symbol or something??
More information about the llvm-commits
mailing list