Add support for llvm.setjmp and longjmp.  Only 3 SingleSource/UnitTests fail now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19404 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index ac48689..f6d4979 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -569,6 +569,7 @@
 }
 
 void SelectionDAGLowering::visitCall(CallInst &I) {
+  const char *RenameFn = 0;
   if (Function *F = I.getCalledFunction())
     switch (F->getIntrinsicID()) {
     case 0: break;  // Not an intrinsic.
@@ -584,6 +585,8 @@
       // readport, writeport, readio, writeio
       assert(0 && "This intrinsic is not implemented yet!");
       return;
+    case Intrinsic::setjmp:  RenameFn = "setjmp"; break;
+    case Intrinsic::longjmp: RenameFn = "longjmp"; break;
     case Intrinsic::memcpy:  visitMemCpy(I); return;
     case Intrinsic::memset:  visitMemSet(I); return;
     case Intrinsic::memmove: visitMemMove(I); return;
@@ -594,7 +597,11 @@
       return;
     }
   
-  SDOperand Callee = getValue(I.getOperand(0));
+  SDOperand Callee;
+  if (!RenameFn)
+    Callee = getValue(I.getOperand(0));
+  else
+    Callee = DAG.getExternalSymbol(RenameFn, TLI.getPointerTy());
   std::vector<std::pair<SDOperand, const Type*> > Args;
   
   for (unsigned i = 1, e = I.getNumOperands(); i != e; ++i) {