aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoconf/configure.ac2
-rw-r--r--include/llvm/Config/config.h.in6
-rw-r--r--include/llvm/Target/TargetLowering.h45
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp4
-rw-r--r--lib/CodeGen/SelectionDAG/TargetLowering.cpp3
-rw-r--r--lib/Target/CBackend/CBackend.cpp8
-rw-r--r--lib/Target/CBackend/Writer.cpp8
-rw-r--r--lib/Target/PowerPC/PPCISelLowering.cpp3
-rw-r--r--lib/Target/X86/X86ISelLowering.cpp15
9 files changed, 54 insertions, 40 deletions
diff --git a/autoconf/configure.ac b/autoconf/configure.ac
index 040ef628f1..3ca2e54a04 100644
--- a/autoconf/configure.ac
+++ b/autoconf/configure.ac
@@ -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
diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in
index 0068c5169c..38aa75f1de 100644
--- a/include/llvm/Config/config.h.in
+++ b/include/llvm/Config/config.h.in
@@ -416,12 +416,6 @@
/* 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
diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h
index 5ebed7a006..cea70d1153 100644
--- a/include/llvm/Target/TargetLowering.h
+++ b/include/llvm/Target/TargetLowering.h
@@ -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;
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index cb408e18a3..d4947a01fe 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -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:
diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 314941a356..79e8013e4f 100644
--- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -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;
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index 3cfd6d0386..250ffc1fb5 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -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 << ", ";
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index 3cfd6d0386..250ffc1fb5 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -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 << ", ";
diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp
index bcdb1e1584..438251735a 100644
--- a/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -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);
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp
index c139dd27e9..5eaac0faea 100644
--- a/lib/Target/X86/X86ISelLowering.cpp
+++ b/lib/Target/X86/X86ISelLowering.cpp
@@ -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);