Modified the code so that it generates (0) for setjmp() and abort() for
authorJohn Criswell <criswell@uiuc.edu>
Thu, 31 Jul 2003 15:11:08 +0000 (15:11 +0000)
committerJohn Criswell <criswell@uiuc.edu>
Thu, 31 Jul 2003 15:11:08 +0000 (15:11 +0000)
longjmp() (and does not include setjmp.h).
This is to fix some problems on Sparc while non-local jumps are still
unimplemented.

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

lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp

index 88cf718dae557829294e1e172b45bf77a5f6e3a3..ad242c77c46eaa1bc2934dd175406f8c86aef4c4 100644 (file)
@@ -570,7 +570,9 @@ void CWriter::printModule(Module *M) {
   // get declaration for alloca
   Out << "/* Provide Declarations */\n";
   Out << "#include <stdarg.h>\n";
+#ifdef HAVE_JUMP
   Out << "#include <setjmp.h>\n";
+#endif
   generateCompilerSpecificCode(Out);
   
   // Provide a definition for `bool' if not compiling with a C++ compiler.
@@ -1123,16 +1125,32 @@ void CWriter::visitCallInst(CallInst &I) {
         return;
         
       case LLVMIntrinsic::setjmp:
+#ifdef HAVE_JUMP
         Out << "setjmp(*(jmp_buf*)";
         writeOperand(I.getOperand(1));
         Out << ")";
+#else
+        //
+        // For right now, we don't really support non-local jumps.  So
+        // make setjmp() always evaluate to zero for now.
+        //
+        Out << "(0)";
+#endif
         return;
       case LLVMIntrinsic::longjmp:
+#ifdef HAVE_JUMP
         Out << "longjmp(*(jmp_buf*)";
         writeOperand(I.getOperand(1));
         Out << ", ";
         writeOperand(I.getOperand(2));
         Out << ")";
+#else
+        //
+        // For right now, we don't really support non-local jumps.  So
+        // make longjmp() abort the program.
+        //
+        Out << "abort()";
+#endif
         return;
       }
     }
index 88cf718dae557829294e1e172b45bf77a5f6e3a3..ad242c77c46eaa1bc2934dd175406f8c86aef4c4 100644 (file)
@@ -570,7 +570,9 @@ void CWriter::printModule(Module *M) {
   // get declaration for alloca
   Out << "/* Provide Declarations */\n";
   Out << "#include <stdarg.h>\n";
+#ifdef HAVE_JUMP
   Out << "#include <setjmp.h>\n";
+#endif
   generateCompilerSpecificCode(Out);
   
   // Provide a definition for `bool' if not compiling with a C++ compiler.
@@ -1123,16 +1125,32 @@ void CWriter::visitCallInst(CallInst &I) {
         return;
         
       case LLVMIntrinsic::setjmp:
+#ifdef HAVE_JUMP
         Out << "setjmp(*(jmp_buf*)";
         writeOperand(I.getOperand(1));
         Out << ")";
+#else
+        //
+        // For right now, we don't really support non-local jumps.  So
+        // make setjmp() always evaluate to zero for now.
+        //
+        Out << "(0)";
+#endif
         return;
       case LLVMIntrinsic::longjmp:
+#ifdef HAVE_JUMP
         Out << "longjmp(*(jmp_buf*)";
         writeOperand(I.getOperand(1));
         Out << ", ";
         writeOperand(I.getOperand(2));
         Out << ")";
+#else
+        //
+        // For right now, we don't really support non-local jumps.  So
+        // make longjmp() abort the program.
+        //
+        Out << "abort()";
+#endif
         return;
       }
     }