Revert 42908 for now.
[oota-llvm.git] / lib / Target / X86 / X86ATTAsmPrinter.cpp
index 4a52269b791158e61b4cae38683c1089f007f1a1..06558771240512f2bdf01b5e07a83276de7293f3 100644 (file)
@@ -31,14 +31,14 @@ using namespace llvm;
 
 STATISTIC(EmittedInsts, "Number of machine instrs printed");
 
-static std::string computePICLabel(const std::string &FnName,
+static std::string computePICLabel(unsigned FnNum,
                                    const TargetAsmInfo *TAI,
                                    const X86Subtarget* Subtarget)  {
   std::string label;
   if (Subtarget->isTargetDarwin())
-    label =  "\"L" "pb$" + FnName + "\"";
+    label =  "\"L" + utostr_32(FnNum) + "$pb\"";
   else if (Subtarget->isTargetELF())
-    label = ".Lllvm$piclabel$" + FnName;
+    label = ".Lllvm$" + utostr_32(FnNum) + "$piclabel";
   else
     assert(0 && "Don't know how to print PIC label!\n");
 
@@ -236,13 +236,13 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
   case MachineOperand::MO_JumpTableIndex: {
     bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
     if (!isMemOp) O << '$';
-    O << TAI->getPrivateGlobalPrefix() << "JTI" << MO.getJumpTableIndex()
-      << '_' << CurrentFnName;
+    O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << "_"
+      << MO.getJumpTableIndex();
 
     if (TM.getRelocationModel() == Reloc::PIC_) {
       if (Subtarget->isPICStyleStub())
-        O << "-\"" << TAI->getPrivateGlobalPrefix() << "pb$" << CurrentFnName
-          << "\"";
+        O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
+          << "$pb\"";
       else if (Subtarget->isPICStyleGOT())
         O << "@GOTOFF";
     }
@@ -254,13 +254,13 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
   case MachineOperand::MO_ConstantPoolIndex: {
     bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
     if (!isMemOp) O << '$';
-    O << TAI->getPrivateGlobalPrefix() << "CPI" << MO.getConstantPoolIndex()
-      << '_' << CurrentFnName;
+    O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
+      << MO.getConstantPoolIndex();
 
     if (TM.getRelocationModel() == Reloc::PIC_) {
       if (Subtarget->isPICStyleStub())
-        O << "-\"" << TAI->getPrivateGlobalPrefix() << "pb$" << CurrentFnName
-          << "\"";
+        O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
+          << "$pb\"";
       else if (Subtarget->isPICStyleGOT())
         O << "@GOTOFF";
     }
@@ -317,8 +317,8 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
       }
       
       if (!isCallOp && TM.getRelocationModel() == Reloc::PIC_)
-        O << "-\"" << TAI->getPrivateGlobalPrefix() << "pb$" << CurrentFnName
-          << "\"";
+        O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
+          << "$pb\"";
     } else {
       if (GV->hasDLLImportLinkage()) {
         O << "__imp_";          
@@ -418,7 +418,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
         //   popl %some_register
         //   addl $_GLOBAL_ADDRESS_TABLE_ + [.-piclabel], %some_register
         O << " + [.-"
-          << computePICLabel(CurrentFnName, TAI, Subtarget) << "]";
+          << computePICLabel(getFunctionNumber(), TAI, Subtarget) << "]";
 
       if (isCallOp)
         O << "@PLT";
@@ -498,7 +498,7 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
 }
 
 void X86ATTAsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) {
-  std::string label = computePICLabel(CurrentFnName, TAI, Subtarget);
+  std::string label = computePICLabel(getFunctionNumber(), TAI, Subtarget);
   O << label << "\n" << label << ":";
 }