[llvm-commits] [llvm] r73529 - in /llvm/trunk: lib/Target/ARM/ARMInstrInfo.cpp test/CodeGen/ARM/vargs2.ll

Anton Korobeynikov asl at math.spbu.ru
Tue Jun 16 11:49:09 PDT 2009


Author: asl
Date: Tue Jun 16 13:49:08 2009
New Revision: 73529

URL: http://llvm.org/viewvc/llvm-project?rev=73529&view=rev
Log:
GNU as refuses to assemble "pop {}" instruction. Do not emit such
(this is the case when we have thumb vararg function with single
callee-saved register, which is handled separately).

Modified:
    llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp
    llvm/trunk/test/CodeGen/ARM/vargs2.ll

Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp?rev=73529&r1=73528&r2=73529&view=diff

==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp Tue Jun 16 13:49:08 2009
@@ -697,7 +697,6 @@
 
   bool isVarArg = AFI->getVarArgsRegSaveSize() > 0;
   MachineInstr *PopMI = MF.CreateMachineInstr(get(ARM::tPOP),MI->getDebugLoc());
-  MBB.insert(MI, PopMI);
   for (unsigned i = CSI.size(); i != 0; --i) {
     unsigned Reg = CSI[i-1].getReg();
     if (Reg == ARM::LR) {
@@ -706,10 +705,15 @@
         continue;
       Reg = ARM::PC;
       PopMI->setDesc(get(ARM::tPOP_RET));
-      MBB.erase(MI);
+      MI = MBB.erase(MI);
     }
     PopMI->addOperand(MachineOperand::CreateReg(Reg, true));
   }
+
+  // It's illegal to emit pop instruction without operands.
+  if (PopMI->getNumOperands() > 0)
+    MBB.insert(MI, PopMI);
+
   return true;
 }
 

Modified: llvm/trunk/test/CodeGen/ARM/vargs2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vargs2.ll?rev=73529&r1=73528&r2=73529&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/ARM/vargs2.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/vargs2.ll Tue Jun 16 13:49:08 2009
@@ -1,6 +1,6 @@
 ; RUN: llvm-as < %s | llc -march=thumb
 ; RUN: llvm-as < %s | llc -march=thumb | \
-; RUN:   grep pop | count 2
+; RUN:   grep pop | count 1
 
 @str = internal constant [4 x i8] c"%d\0A\00"           ; <[4 x i8]*> [#uses=1]
 





More information about the llvm-commits mailing list