[llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrSelection.cpp

Vikram Adve vadve at cs.uiuc.edu
Tue Sep 16 00:57:02 PDT 2003


Changes in directory llvm/lib/Target/Sparc:

SparcInstrSelection.cpp updated: 1.117 -> 1.118

---
Log message:

Fix longjmp case so that, along with the call to abort(), we also
generate the appropriate CallArgsDescriptor and tmp. virtual regs.


---
Diffs of the changes:

Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp
diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.117 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.118
--- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.117	Mon Aug 18 11:06:09 2003
+++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp	Tue Sep 16 00:56:22 2003
@@ -1446,8 +1446,28 @@
   case LLVMIntrinsic::longjmp: {
     // call abort()
     Module* M = callInstr.getParent()->getParent()->getParent();
-    Function *F = M->getNamedFunction("abort");
-    mvec.push_back(BuildMI(V9::CALL, 1).addReg(F));
+    const FunctionType *voidvoidFuncTy =
+      FunctionType::get(Type::VoidTy, std::vector<const Type*>(), false);
+    Function *F = M->getOrInsertFunction("abort", voidvoidFuncTy);
+    assert(F && "Unable to get or create `abort' function declaration");
+
+    // Create hidden virtual register for return address with type void*
+    TmpInstruction* retAddrReg =
+      new TmpInstruction(MachineCodeForInstruction::get(&callInstr),
+                         PointerType::get(Type::VoidTy), &callInstr);
+    
+    // Use a descriptor to pass information about call arguments
+    // to the register allocator.  This descriptor will be "owned"
+    // and freed automatically when the MachineCodeForInstruction
+    // object for the callInstr goes away.
+    CallArgsDescriptor* argDesc =
+      new CallArgsDescriptor(&callInstr, retAddrReg, false, false);
+
+    MachineInstr* callMI = BuildMI(V9::CALL, 1).addPCDisp(F);
+    callMI->addImplicitRef(retAddrReg, /*isDef*/ true);
+    
+    mvec.push_back(callMI);
+    mvec.push_back(BuildMI(V9::NOP, 0));
     return true;
   }
 





More information about the llvm-commits mailing list