Fix longjmp case so that, along with the call to abort(), we also
authorVikram S. Adve <vadve@cs.uiuc.edu>
Tue, 16 Sep 2003 05:56:22 +0000 (05:56 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Tue, 16 Sep 2003 05:56:22 +0000 (05:56 +0000)
generate the appropriate CallArgsDescriptor and tmp. virtual regs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8554 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/SparcV9/SparcV9InstrSelection.cpp

index ee24333495129794beb50640b62fd48aee7dab30..b5a6fe0c4c917e9bf7c75bc6f2df52a58f4e6f7e 100644 (file)
@@ -1446,8 +1446,28 @@ bool CodeGenIntrinsic(LLVMIntrinsic::ID iid, CallInst &callInstr,
   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;
   }