[llvm-commits] [llvm] r81511 - in /llvm/trunk/lib/Target/X86/AsmPrinter: X86ATTAsmPrinter.cpp X86ATTAsmPrinter.h X86MCInstLower.cpp
Chris Lattner
sabre at nondot.org
Thu Sep 10 23:36:33 PDT 2009
Author: lattner
Date: Fri Sep 11 01:36:33 2009
New Revision: 81511
URL: http://llvm.org/viewvc/llvm-project?rev=81511&view=rev
Log:
change FnStubs from being a StringMap<std::string> to being a much
more efficient SmallPtrSet<MCSymbol*>. This eliminates string
craziness and fixes CodeGen/X86/darwin-quote.ll with the new asmprinter.
Codegen is producing stubs in a nondeterminstic order, but it was doing
this before anyway.
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=81511&r1=81510&r2=81511&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Fri Sep 11 01:36:33 2009
@@ -24,8 +24,10 @@
#include "llvm/Module.h"
#include "llvm/Type.h"
#include "llvm/Assembly/Writer.h"
-#include "llvm/MC/MCStreamer.h"
+#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSectionMachO.h"
+#include "llvm/MC/MCStreamer.h"
+#include "llvm/MC/MCSymbol.h"
#include "llvm/CodeGen/MachineJumpTableInfo.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
@@ -320,8 +322,9 @@
GVStubs[Name] = Mang->getMangledName(GV);
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[Name] = Mang->getMangledName(GV);
+ else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
+ FnStubs.insert(OutContext.GetOrCreateSymbol(Name));
+ }
// If the name begins with a dollar-sign, enclose it in parens. We do this
// to avoid having it look like an integer immediate to the assembler.
@@ -336,8 +339,8 @@
case MachineOperand::MO_ExternalSymbol: {
std::string Name = Mang->makeNameProper(MO.getSymbolName());
if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
- FnStubs[Name+"$stub"] = Name;
Name += "$stub";
+ FnStubs.insert(OutContext.GetOrCreateSymbol(Name));
}
// If the name begins with a dollar-sign, enclose it in parens. We do this
@@ -881,10 +884,20 @@
MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
5, SectionKind::getMetadata());
OutStreamer.SwitchSection(TheSection);
- for (StringMap<std::string>::iterator I = FnStubs.begin(),
- E = FnStubs.end(); I != E; ++I)
- O << I->getKeyData() << ":\n" << "\t.indirect_symbol " << I->second
- << "\n\thlt ; hlt ; hlt ; hlt ; hlt\n";
+ // FIXME: This iteration order is unstable!!
+ for (SmallPtrSet<MCSymbol*, 16>::iterator I = FnStubs.begin(),
+ E = FnStubs.end(); I != E; ++I) {
+ MCSymbol *Sym = *I;
+ Sym->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);
+ O << "\n\thlt ; hlt ; hlt ; hlt ; hlt\n";
+ }
O << '\n';
}
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=81511&r1=81510&r2=81511&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Fri Sep 11 01:36:33 2009
@@ -216,7 +216,8 @@
void emitFunctionHeader(const MachineFunction &MF);
// Necessary for Darwin to print out the apprioriate types of linker stubs
- StringMap<std::string> FnStubs, GVStubs, HiddenGVStubs;
+ StringMap<std::string> GVStubs, HiddenGVStubs;
+ SmallPtrSet<MCSymbol*, 16> FnStubs; // Darwin $stub stubs.
// 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=81511&r1=81510&r2=81511&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Fri Sep 11 01:36:33 2009
@@ -78,10 +78,12 @@
Name += "$non_lazy_ptr";
HiddenGVStubs[Name.str()] = StringRef(Name.data(), Name.size()-13);
break;
- case X86II::MO_DARWIN_STUB:
+ case X86II::MO_DARWIN_STUB: {
Name += "$stub";
- FnStubs[Name.str()] = StringRef(Name.data(), Name.size()-5);
- break;
+ MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name.str());
+ FnStubs.insert(Sym);
+ return Sym;
+ }
// FIXME: These probably should be a modifier on the symbol or something??
case X86II::MO_TLSGD: Name += "@TLSGD"; break;
case X86II::MO_GOTTPOFF: Name += "@GOTTPOFF"; break;
@@ -114,12 +116,13 @@
Name.insert(Name.begin(), Prefix, Prefix+strlen(Prefix));
break;
}
- case X86II::MO_DARWIN_STUB:
- // Insert: FnStub["_foo$stub"] = "_foo";
+ case X86II::MO_DARWIN_STUB: {
Name += "$stub";
- FnStubs[Name.str()] = StringRef(Name.data(), Name.size()-5);
- break;
- // FIXME: These probably should be a modifier on the symbol or something??
+ MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name.str());
+ FnStubs.insert(Sym);
+ return Sym;
+ }
+ // FIXME: These probably should be a modifier on the symbol or something??
case X86II::MO_TLSGD: Name += "@TLSGD"; break;
case X86II::MO_GOTTPOFF: Name += "@GOTTPOFF"; break;
case X86II::MO_INDNTPOFF: Name += "@INDNTPOFF"; break;
More information about the llvm-commits
mailing list