[llvm-commits] [llvm] r81508 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
Chris Lattner
sabre at nondot.org
Thu Sep 10 22:58:44 PDT 2009
Author: lattner
Date: Fri Sep 11 00:58:44 2009
New Revision: 81508
URL: http://llvm.org/viewvc/llvm-project?rev=81508&view=rev
Log:
reimplement X86ATTAsmPrinter::GetGlobalAddressSymbol in terms of
Mangler::getNameWithPrefix. In addition to avoiding some over
quoting, this also is more efficient because it uses smallvector
instead of std::string thrashing.
Modified:
llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
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=81508&r1=81507&r2=81508&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Fri Sep 11 00:58:44 2009
@@ -44,15 +44,16 @@
MCSymbol *X86ATTAsmPrinter::GetGlobalAddressSymbol(const MachineOperand &MO) {
const GlobalValue *GV = MO.getGlobal();
- const char *Suffix = "";
- if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
- Suffix = "$stub";
- else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
- MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
- MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
- Suffix = "$non_lazy_ptr";
+ bool isImplicitlyPrivate = false;
+ if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB ||
+ MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
+ MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
+ MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
+ isImplicitlyPrivate = true;
+
+ SmallString<128> Name;
+ Mang->getNameWithPrefix(Name, GV, isImplicitlyPrivate);
- std::string Name = Mang->getMangledName(GV, Suffix, Suffix[0] != '\0');
if (Subtarget->isTargetCygMing())
DecorateCygMingName(Name, GV);
@@ -62,19 +63,24 @@
case X86II::MO_GOT_ABSOLUTE_ADDRESS: // Doesn't modify symbol name.
case X86II::MO_PIC_BASE_OFFSET: // Doesn't modify symbol name.
break;
- case X86II::MO_DLLIMPORT:
+ case X86II::MO_DLLIMPORT: {
// Handle dllimport linkage.
- Name = "__imp_" + Name;
+ const char *Prefix = "__imp_";
+ Name.insert(Name.begin(), Prefix, Prefix+strlen(Prefix));
break;
+ }
case X86II::MO_DARWIN_NONLAZY:
case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
- GVStubs[Name] = Mang->getMangledName(GV);
+ Name += "$non_lazy_ptr";
+ GVStubs[Name.str()] = StringRef(Name.data(), Name.size()-13);
break;
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
- HiddenGVStubs[Name] = Mang->getMangledName(GV);
+ Name += "$non_lazy_ptr";
+ HiddenGVStubs[Name.str()] = StringRef(Name.data(), Name.size()-13);
break;
case X86II::MO_DARWIN_STUB:
- FnStubs[Name] = Mang->getMangledName(GV);
+ Name += "$stub";
+ FnStubs[Name.str()] = StringRef(Name.data(), Name.size()-5);
break;
// FIXME: These probably should be a modifier on the symbol or something??
case X86II::MO_TLSGD: Name += "@TLSGD"; break;
@@ -88,11 +94,11 @@
case X86II::MO_PLT: Name += "@PLT"; break;
}
- return OutContext.GetOrCreateSymbol(Name);
+ return OutContext.GetOrCreateSymbol(Name.str());
}
MCSymbol *X86ATTAsmPrinter::GetExternalSymbolSymbol(const MachineOperand &MO) {
- SmallString<256> Name;
+ SmallString<128> Name;
Name += MAI->getGlobalPrefix();
Name += MO.getSymbolName();
More information about the llvm-commits
mailing list