[llvm-commits] [llvm] r74105 - in /llvm/trunk/lib/Target/X86/AsmPrinter: X86ATTAsmPrinter.cpp X86ATTAsmPrinter.h
Chris Lattner
sabre at nondot.org
Wed Jun 24 12:19:17 PDT 2009
Author: lattner
Date: Wed Jun 24 14:19:16 2009
New Revision: 74105
URL: http://llvm.org/viewvc/llvm-project?rev=74105&view=rev
Log:
reimplement getPICLabelString as PrintPICBaseSymbol to eliminate std::string heap thrashing.
Modified:
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
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=74105&r1=74104&r2=74105&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Wed Jun 24 14:19:16 2009
@@ -43,20 +43,17 @@
static cl::opt<bool> NewAsmPrinter("experimental-asm-printer",
cl::Hidden);
-static std::string getPICLabelString(unsigned FnNum,
- const TargetAsmInfo *TAI,
- const X86Subtarget* Subtarget) {
- std::string label;
+
+void X86ATTAsmPrinter::PrintPICBaseSymbol() const {
if (Subtarget->isTargetDarwin())
- label = "\"L" + utostr_32(FnNum) + "$pb\"";
+ O << "\"L" << getFunctionNumber() << "$pb\"";
else if (Subtarget->isTargetELF())
- label = ".Lllvm$" + utostr_32(FnNum) + "." "$piclabel";
+ O << ".Lllvm$" << getFunctionNumber() << "." "$piclabel";
else
assert(0 && "Don't know how to print PIC label!\n");
-
- return label;
}
+
static X86MachineFunctionInfo calculateFunctionInfo(const Function *F,
const TargetData *TD) {
X86MachineFunctionInfo Info;
@@ -403,7 +400,7 @@
if (shouldPrintPLT(TM, Subtarget)) {
std::string GOTName(TAI->getGlobalPrefix());
GOTName+="_GLOBAL_OFFSET_TABLE_";
- if (Name == GOTName)
+ if (Name == GOTName) {
// HACK! Emit extra offset to PC during printing GOT offset to
// compensate for the size of popl instruction. The resulting code
// should look like:
@@ -411,8 +408,10 @@
// piclabel:
// popl %some_register
// addl $_GLOBAL_ADDRESS_TABLE_ + [.-piclabel], %some_register
- O << " + [.-"
- << getPICLabelString(getFunctionNumber(), TAI, Subtarget) << ']';
+ O << " + [.-";
+ PrintPICBaseSymbol();
+ O << ']';
+ }
O << "@PLT";
}
@@ -538,8 +537,10 @@
O << Name;
}
- if (TM.getRelocationModel() == Reloc::PIC_)
- O << '-' << getPICLabelString(getFunctionNumber(), TAI, Subtarget);
+ if (TM.getRelocationModel() == Reloc::PIC_) {
+ O << '-';
+ PrintPICBaseSymbol();
+ }
} else {
if (GV->hasDLLImportLinkage())
O << "__imp_";
@@ -626,7 +627,7 @@
if (shouldPrintPLT(TM, Subtarget)) {
std::string GOTName(TAI->getGlobalPrefix());
GOTName+="_GLOBAL_OFFSET_TABLE_";
- if (Name == GOTName)
+ if (Name == GOTName) {
// HACK! Emit extra offset to PC during printing GOT offset to
// compensate for the size of popl instruction. The resulting code
// should look like:
@@ -634,8 +635,10 @@
// piclabel:
// popl %some_register
// addl $_GLOBAL_ADDRESS_TABLE_ + [.-piclabel], %some_register
- O << " + [.-"
- << getPICLabelString(getFunctionNumber(), TAI, Subtarget) << ']';
+ O << " + [.-";
+ PrintPICBaseSymbol();
+ O << ']';
+ }
}
if (needCloseParen)
@@ -737,13 +740,19 @@
if (Subtarget->isPICStyleRIPRel())
O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << uid << '\n';
- else
- O << '-' << getPICLabelString(getFunctionNumber(), TAI, Subtarget) << '\n';
+ else {
+ O << '-';
+ PrintPICBaseSymbol();
+ O << '\n';
+ }
}
+
void X86ATTAsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) {
- std::string label = getPICLabelString(getFunctionNumber(), TAI, Subtarget);
- O << label << '\n' << label << ':';
+ PrintPICBaseSymbol();
+ O << '\n';
+ PrintPICBaseSymbol();
+ O << ':';
}
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=74105&r1=74104&r2=74105&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Wed Jun 24 14:19:16 2009
@@ -187,6 +187,8 @@
void printPICLabel(const MachineInstr *MI, unsigned Op);
void printModuleLevelGV(const GlobalVariable* GVar);
+ void PrintPICBaseSymbol() const;
+
bool runOnMachineFunction(MachineFunction &F);
void emitFunctionHeader(const MachineFunction &MF);
More information about the llvm-commits
mailing list