[llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Feb 15 16:52:01 PST 2004


Changes in directory llvm/lib/Target/CBackend:

Writer.cpp updated: 1.161 -> 1.162

---
Log message:

Now that the lowerinvoke pass inserts calls to llvm.setjmp/llvm.longjmp, some
hacks can be banished.  Also, this gives us the opportunity to emit special code
for the setjmp/longjmps which alows the elimination of one GCC warning for every
setjmp/longjmp site (which is often THOUSANDS in C++ programs).  Yaay!


---
Diffs of the changes:  (+15 -2)

Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.161 llvm/lib/Target/CBackend/Writer.cpp:1.162
--- llvm/lib/Target/CBackend/Writer.cpp:1.161	Sat Feb 14 23:54:27 2004
+++ llvm/lib/Target/CBackend/Writer.cpp	Sun Feb 15 16:51:47 2004
@@ -686,8 +686,7 @@
     Out << "\n/* Function Declarations */\n";
     for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
       // Don't print declarations for intrinsic functions.
-      if (!I->getIntrinsicID() &&
-          I->getName() != "setjmp" && I->getName() != "longjmp") {
+      if (!I->getIntrinsicID()) {
         printFunctionSignature(I, true);
         if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__";
         Out << ";\n";
@@ -1187,6 +1186,8 @@
             case Intrinsic::va_end:
             case Intrinsic::returnaddress:
             case Intrinsic::frameaddress:
+            case Intrinsic::setjmp:
+            case Intrinsic::longjmp:
               // We directly implement these intrinsics
               break;
             default:
@@ -1243,6 +1244,18 @@
       case Intrinsic::frameaddress:
         Out << "__builtin_frame_address(";
         writeOperand(I.getOperand(1));
+        Out << ")";
+        return;
+      case Intrinsic::setjmp:
+        Out << "setjmp(*(jmp_buf*)";
+        writeOperand(I.getOperand(1));
+        Out << ")";
+        return;
+      case Intrinsic::longjmp:
+        Out << "longjmp(*(jmp_buf*)";
+        writeOperand(I.getOperand(1));
+        Out << ", ";
+        writeOperand(I.getOperand(2));
         Out << ")";
         return;
       }





More information about the llvm-commits mailing list