Cleaned setjmp/longjmp lowering interfaces. Now we're producing right
authorAnton Korobeynikov <asl@math.spbu.ru>
Sun, 10 Dec 2006 23:12:42 +0000 (23:12 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Sun, 10 Dec 2006 23:12:42 +0000 (23:12 +0000)
code (both asm & cbe) for Mingw32 target.
Removed autoconf checks for underscored versions of setjmp/longjmp.

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

autoconf/configure.ac
include/llvm/Config/config.h.in
include/llvm/Target/TargetLowering.h
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
lib/CodeGen/SelectionDAG/TargetLowering.cpp
lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/X86/X86ISelLowering.cpp

index 040ef628f1eba384f15867db6d6c6c14b5bc3e17..3ca2e54a047b296c40c8da6312a08a87f3ff6db5 100644 (file)
@@ -670,7 +670,7 @@ AC_CHECK_FUNCS([backtrace ceilf floorf roundf rintf nearbyintf getcwd ])
 AC_CHECK_FUNCS([getpagesize getrusage gettimeofday isatty mkdtemp mkstemp ])
 AC_CHECK_FUNCS([mktemp realpath sbrk setrlimit strdup strerror strerror_r ])
 AC_CHECK_FUNCS([strtoll strtoq sysconf malloc_zone_statistics ])
-AC_CHECK_FUNCS([_setjmp _longjmp setjmp longjmp sigsetjmp siglongjmp])
+AC_CHECK_FUNCS([setjmp longjmp sigsetjmp siglongjmp])
 AC_C_PRINTF_A
 AC_FUNC_ALLOCA
 AC_FUNC_RAND48
index 0068c5169c2ebddbeddb93f85764d664ece0fad5..38aa75f1de52567745f3a14bbd2ada95e86a33ec 100644 (file)
 /* Define to 1 if you have the <windows.h> header file. */
 #undef HAVE_WINDOWS_H
 
-/* Define to 1 if you have the `_longjmp' function. */
-#undef HAVE__LONGJMP
-
-/* Define to 1 if you have the `_setjmp' function. */
-#undef HAVE__SETJMP
-
 /* Installation directory for binary executables */
 #undef LLVM_BINDIR
 
index 5ebed7a0062b66ff237220ca92d9d74c9662b294..cea70d115391de09f56283ac8345ce501505727f 100644 (file)
@@ -379,12 +379,18 @@ public:
     return allowUnalignedMemoryAccesses;
   }
   
-  /// usesUnderscoreSetJmpLongJmp - Determine if we should use _setjmp or setjmp
+  /// usesUnderscoreSetJmp - Determine if we should use _setjmp or setjmp
   /// to implement llvm.setjmp.
-  bool usesUnderscoreSetJmpLongJmp() const {
-    return UseUnderscoreSetJmpLongJmp;
+  bool usesUnderscoreSetJmp() const {
+    return UseUnderscoreSetJmp;
   }
-  
+
+  /// usesUnderscoreLongJmp - Determine if we should use _longjmp or longjmp
+  /// to implement llvm.longjmp.
+  bool usesUnderscoreLongJmp() const {
+    return UseUnderscoreLongJmp;
+  }
+
   /// getStackPointerRegisterToSaveRestore - If a physical register, this
   /// specifies the register that llvm.savestack/llvm.restorestack should save
   /// and restore.
@@ -564,13 +570,20 @@ protected:
     ShiftAmtHandling = OORSA;
   }
 
-  /// setUseUnderscoreSetJmpLongJmp - Indicate whether this target prefers to
-  /// use _setjmp and _longjmp to or implement llvm.setjmp/llvm.longjmp or
-  /// the non _ versions.  Defaults to false.
-  void setUseUnderscoreSetJmpLongJmp(bool Val) {
-    UseUnderscoreSetJmpLongJmp = Val;
+  /// setUseUnderscoreSetJmp - Indicate whether this target prefers to
+  /// use _setjmp to implement llvm.setjmp or the non _ version.
+  /// Defaults to false.
+  void setUseUnderscoreSetJmp(bool Val) {
+    UseUnderscoreSetJmp = Val;
   }
-  
+
+  /// setUseUnderscoreLongJmp - Indicate whether this target prefers to
+  /// use _longjmp to implement llvm.longjmp or the non _ version.
+  /// Defaults to false.
+  void setUseUnderscoreLongJmp(bool Val) {
+    UseUnderscoreLongJmp = Val;
+  }
+
   /// setStackPointerRegisterToSaveRestore - If set to a physical register, this
   /// specifies the register that llvm.savestack/llvm.restorestack should save
   /// and restore.
@@ -883,10 +896,14 @@ private:
   /// total cycles or lowest register usage.
   SchedPreference SchedPreferenceInfo;
   
-  /// UseUnderscoreSetJmpLongJmp - This target prefers to use _setjmp and
-  /// _longjmp to implement llvm.setjmp/llvm.longjmp.  Defaults to false.
-  bool UseUnderscoreSetJmpLongJmp;
-  
+  /// UseUnderscoreSetJmp - This target prefers to use _setjmp to implement
+  /// llvm.setjmp.  Defaults to false.
+  bool UseUnderscoreSetJmp;
+
+  /// UseUnderscoreLongJmp - This target prefers to use _longjmp to implement
+  /// llvm.longjmp.  Defaults to false.
+  bool UseUnderscoreLongJmp;
+
   /// JumpBufSize - The size, in bytes, of the target's jmp_buf buffers
   unsigned JumpBufSize;
   
index cb408e18a3b5e303e29ff815a5b088000c373c1a..d4947a01fede696b0a6c2810cc34461615c9248b 100644 (file)
@@ -1974,10 +1974,10 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
   case Intrinsic::returnaddress: visitFrameReturnAddress(I, false); return 0;
   case Intrinsic::frameaddress:  visitFrameReturnAddress(I, true); return 0;
   case Intrinsic::setjmp:
-    return "_setjmp"+!TLI.usesUnderscoreSetJmpLongJmp();
+    return "_setjmp"+!TLI.usesUnderscoreSetJmp();
     break;
   case Intrinsic::longjmp:
-    return "_longjmp"+!TLI.usesUnderscoreSetJmpLongJmp();
+    return "_longjmp"+!TLI.usesUnderscoreLongJmp();
     break;
   case Intrinsic::memcpy_i32:
   case Intrinsic::memcpy_i64:
index 314941a3561328cc783df2978bafa95d37a345ff..79e8013e4f585e3fc1c349f6e788a3b07e2a6abc 100644 (file)
@@ -47,7 +47,8 @@ TargetLowering::TargetLowering(TargetMachine &tm)
          sizeof(TargetDAGCombineArray)/sizeof(TargetDAGCombineArray[0]));
   maxStoresPerMemset = maxStoresPerMemcpy = maxStoresPerMemmove = 8;
   allowUnalignedMemoryAccesses = false;
-  UseUnderscoreSetJmpLongJmp = false;
+  UseUnderscoreSetJmp = false;
+  UseUnderscoreLongJmp = false;
   IntDivIsCheap = false;
   Pow2DivIsCheap = false;
   StackPointerRegisterToSaveRestore = 0;
index 3cfd6d0386a8a66d64532fb72c033cb412dc7105..250ffc1fb50e61eb2ef3e88e97834e1f1f0f988f 100644 (file)
@@ -1136,6 +1136,8 @@ static void generateCompilerSpecificCode(std::ostream& Out) {
       << "#elif defined(__APPLE__)\n"
       << "extern void *__builtin_alloca(unsigned long);\n"
       << "#define alloca(x) __builtin_alloca(x)\n"
+      << "#define longjmp _longjmp\n"
+      << "#define setjmp _setjmp\n"
       << "#elif defined(__sun__)\n"
       << "#if defined(__sparcv9)\n"
       << "extern void *__builtin_alloca(unsigned long);\n"
@@ -2141,17 +2143,11 @@ void CWriter::visitCallInst(CallInst &I) {
         Out << ')';
         return;
       case Intrinsic::setjmp:
-#if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
-        Out << "_";  // Use _setjmp on systems that support it!
-#endif
         Out << "setjmp(*(jmp_buf*)";
         writeOperand(I.getOperand(1));
         Out << ')';
         return;
       case Intrinsic::longjmp:
-#if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
-        Out << "_";  // Use _longjmp on systems that support it!
-#endif
         Out << "longjmp(*(jmp_buf*)";
         writeOperand(I.getOperand(1));
         Out << ", ";
index 3cfd6d0386a8a66d64532fb72c033cb412dc7105..250ffc1fb50e61eb2ef3e88e97834e1f1f0f988f 100644 (file)
@@ -1136,6 +1136,8 @@ static void generateCompilerSpecificCode(std::ostream& Out) {
       << "#elif defined(__APPLE__)\n"
       << "extern void *__builtin_alloca(unsigned long);\n"
       << "#define alloca(x) __builtin_alloca(x)\n"
+      << "#define longjmp _longjmp\n"
+      << "#define setjmp _setjmp\n"
       << "#elif defined(__sun__)\n"
       << "#if defined(__sparcv9)\n"
       << "extern void *__builtin_alloca(unsigned long);\n"
@@ -2141,17 +2143,11 @@ void CWriter::visitCallInst(CallInst &I) {
         Out << ')';
         return;
       case Intrinsic::setjmp:
-#if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
-        Out << "_";  // Use _setjmp on systems that support it!
-#endif
         Out << "setjmp(*(jmp_buf*)";
         writeOperand(I.getOperand(1));
         Out << ')';
         return;
       case Intrinsic::longjmp:
-#if defined(HAVE__SETJMP) && defined(HAVE__LONGJMP)
-        Out << "_";  // Use _longjmp on systems that support it!
-#endif
         Out << "longjmp(*(jmp_buf*)";
         writeOperand(I.getOperand(1));
         Out << ", ";
index bcdb1e1584fe5c1b4754ca25811f64c133be6d65..438251735a483bd04c35c093c352a75a9d0a9bf8 100644 (file)
@@ -41,7 +41,8 @@ PPCTargetLowering::PPCTargetLowering(PPCTargetMachine &TM)
   setPow2DivIsCheap();
   
   // Use _setjmp/_longjmp instead of setjmp/longjmp.
-  setUseUnderscoreSetJmpLongJmp(true);
+  setUseUnderscoreSetJmp(true);
+  setUseUnderscoreLongJmp(true);
     
   // Set up the register classes.
   addRegisterClass(MVT::i32, PPC::GPRCRegisterClass);
index c139dd27e9b3ac368005878c76581d20052ca228..5eaac0faeaf007f84686e57752cd15ab2abd0f5b 100644 (file)
@@ -54,10 +54,19 @@ X86TargetLowering::X86TargetLowering(TargetMachine &TM)
   setShiftAmountFlavor(Mask);   // shl X, 32 == shl X, 0
   setStackPointerRegisterToSaveRestore(X86StackPtr);
 
-  if (!Subtarget->isTargetDarwin())
+  if (Subtarget->isTargetDarwin()) {
     // Darwin should use _setjmp/_longjmp instead of setjmp/longjmp.
-    setUseUnderscoreSetJmpLongJmp(true);
-
+    setUseUnderscoreSetJmp(false);
+    setUseUnderscoreLongJmp(false);
+  } else if (Subtarget->isTargetCygwin()) {
+    // MS runtime is weird: it exports _setjmp, but longjmp!
+    setUseUnderscoreSetJmp(true);
+    setUseUnderscoreLongJmp(false);
+  } else {
+    setUseUnderscoreSetJmp(true);
+    setUseUnderscoreLongJmp(true);
+  }
+  
   // Add legal addressing mode scale values.
   addLegalAddressScale(8);
   addLegalAddressScale(4);