mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-03 02:31:26 +00:00
Fix a bug I introduced in FnStubs generation, switch GVStubs to be a
densemap instead of StringMap to match FnStubs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81513 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2a3c20bf26
commit
46091d70f5
@ -318,12 +318,30 @@ void X86ATTAsmPrinter::printSymbolOperand(const MachineOperand &MO) {
|
||||
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 @@ void X86ATTAsmPrinter::printSymbolOperand(const MachineOperand &MO) {
|
||||
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 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {
|
||||
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 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {
|
||||
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 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {
|
||||
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()) {
|
||||
|
@ -216,8 +216,9 @@ 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> 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;
|
||||
|
@ -70,10 +70,18 @@ MCSymbol *X86ATTAsmPrinter::GetGlobalAddressSymbol(const MachineOperand &MO) {
|
||||
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 @@ MCSymbol *X86ATTAsmPrinter::GetGlobalAddressSymbol(const MachineOperand &MO) {
|
||||
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 @@ MCSymbol *X86ATTAsmPrinter::GetExternalSymbolSymbol(const MachineOperand &MO) {
|
||||
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??
|
||||
|
Loading…
x
Reference in New Issue
Block a user