Split the ENABLE_THREADS #define in two. Now ENABLE_THREADS indicates the ability to run multiple threads at once in the JIT, and requires only

mutex support.  LLVM_MULTITHREADED indicates (or will indicate) the ability to run LLVM itself across multiple threads, and requires atomics support.

llvm-svn: 72140
This commit is contained in:
Owen Anderson 2009-05-19 22:18:56 +00:00
parent c25f766065
commit af5db8335b
3 changed files with 66 additions and 67 deletions

View File

@ -372,6 +372,7 @@ case "$enableval" in
default) AC_SUBST(ENABLE_THREADS,[1]) ;;
*) AC_MSG_ERROR([Invalid setting for --enable-threads. Use "yes" or "no"]) ;;
esac
AC_DEFINE_UNQUOTED([ENABLE_THREADS],$ENABLE_THREADS,[Define if threads enabled])
dnl Allow building without position independent code
AC_ARG_ENABLE(pic,
@ -897,24 +898,22 @@ if test "$llvm_cv_platform_type" = "Unix" ; then
fi
dnl atomic builtins are required for threading support.
if test "$ENABLE_THREADS" -eq 1 ; then
AC_MSG_CHECKING(for GCC atomic builtins)
AC_LINK_IFELSE(
AC_LANG_SOURCE(
[[int main() {
volatile unsigned long val = 1;
__sync_synchronize();
__sync_val_compare_and_swap(&val, 1, 0);
return 0;
}
]]),
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)
AC_SUBST(ENABLE_THREADS, [0])
AC_MSG_WARN([Threading support disabled because atomic builtins are missing]))
fi
AC_MSG_CHECKING(for GCC atomic builtins)
AC_LINK_IFELSE(
AC_LANG_SOURCE(
[[int main() {
volatile unsigned long val = 1;
__sync_synchronize();
__sync_val_compare_and_swap(&val, 1, 0);
return 0;
}
]]),
AC_MSG_RESULT(yes)
AC_DEFINE(LLVM_MULTITHREADED, 1, Build multithreading support into LLVM),
AC_MSG_RESULT(no)
AC_DEFINE(LLVM_MULTITHREADED, 0, Build multithreading support into LLVM)
AC_MSG_WARN([LLVM will be built thread-unsafe because atomic builtins are missing]))
AC_DEFINE_UNQUOTED([ENABLE_THREADS],$ENABLE_THREADS,[Define if threads enabled])
dnl===-----------------------------------------------------------------------===
dnl===

88
llvm/configure vendored
View File

@ -4870,6 +4870,11 @@ echo "$as_me: error: Invalid setting for --enable-threads. Use \"yes\" or \"no\"
{ (exit 1); exit 1; }; } ;;
esac
cat >>confdefs.h <<_ACEOF
#define ENABLE_THREADS $ENABLE_THREADS
_ACEOF
# Check whether --enable-pic was given.
if test "${enable_pic+set}" = set; then
enableval=$enable_pic;
@ -10570,7 +10575,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 10573 "configure"
#line 10578 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -12714,7 +12719,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 12717 "configure"' > conftest.$ac_ext
echo '#line 12722 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@ -14432,11 +14437,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14435: $lt_compile\"" >&5)
(eval echo "\"\$as_me:14440: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:14439: \$? = $ac_status" >&5
echo "$as_me:14444: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@ -14700,11 +14705,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14703: $lt_compile\"" >&5)
(eval echo "\"\$as_me:14708: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:14707: \$? = $ac_status" >&5
echo "$as_me:14712: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@ -14804,11 +14809,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14807: $lt_compile\"" >&5)
(eval echo "\"\$as_me:14812: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:14811: \$? = $ac_status" >&5
echo "$as_me:14816: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@ -17256,7 +17261,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 17259 "configure"
#line 17264 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -17356,7 +17361,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 17359 "configure"
#line 17364 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -19724,11 +19729,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:19727: $lt_compile\"" >&5)
(eval echo "\"\$as_me:19732: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:19731: \$? = $ac_status" >&5
echo "$as_me:19736: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@ -19828,11 +19833,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:19831: $lt_compile\"" >&5)
(eval echo "\"\$as_me:19836: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:19835: \$? = $ac_status" >&5
echo "$as_me:19840: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@ -21398,11 +21403,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:21401: $lt_compile\"" >&5)
(eval echo "\"\$as_me:21406: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:21405: \$? = $ac_status" >&5
echo "$as_me:21410: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@ -21502,11 +21507,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:21505: $lt_compile\"" >&5)
(eval echo "\"\$as_me:21510: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:21509: \$? = $ac_status" >&5
echo "$as_me:21514: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@ -23737,11 +23742,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:23740: $lt_compile\"" >&5)
(eval echo "\"\$as_me:23745: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:23744: \$? = $ac_status" >&5
echo "$as_me:23749: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@ -24005,11 +24010,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:24008: $lt_compile\"" >&5)
(eval echo "\"\$as_me:24013: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:24012: \$? = $ac_status" >&5
echo "$as_me:24017: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@ -24109,11 +24114,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:24112: $lt_compile\"" >&5)
(eval echo "\"\$as_me:24117: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:24116: \$? = $ac_status" >&5
echo "$as_me:24121: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@ -33602,21 +33607,20 @@ echo "$as_me: WARNING: mmap() of files required but not found" >&2;}
fi
fi
if test "$ENABLE_THREADS" -eq 1 ; then
{ echo "$as_me:$LINENO: checking for GCC atomic builtins" >&5
{ echo "$as_me:$LINENO: checking for GCC atomic builtins" >&5
echo $ECHO_N "checking for GCC atomic builtins... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int main() {
volatile unsigned long val = 1;
__sync_synchronize();
__sync_val_compare_and_swap(&val, 1, 0);
return 0;
}
volatile unsigned long val = 1;
__sync_synchronize();
__sync_val_compare_and_swap(&val, 1, 0);
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
@ -33655,26 +33659,28 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(exit $ac_status); }; }; then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
cat >>confdefs.h <<\_ACEOF
#define LLVM_MULTITHREADED 1
_ACEOF
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
ENABLE_THREADS=0
{ echo "$as_me:$LINENO: WARNING: Threading support disabled because atomic builtins are missing" >&5
echo "$as_me: WARNING: Threading support disabled because atomic builtins are missing" >&2;}
cat >>confdefs.h <<\_ACEOF
#define LLVM_MULTITHREADED 0
_ACEOF
{ echo "$as_me:$LINENO: WARNING: LLVM will be built thread-unsafe because atomic builtins are missing" >&5
echo "$as_me: WARNING: LLVM will be built thread-unsafe because atomic builtins are missing" >&2;}
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
cat >>confdefs.h <<_ACEOF
#define ENABLE_THREADS $ENABLE_THREADS
_ACEOF

View File

@ -23,14 +23,8 @@ namespace llvm {
namespace sys {
inline void MemoryFence() {
#if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0
# if defined(__GNUC__)
__asm__ __volatile__("" : : : "memory");
# elif defined(_MSC_VER)
__asm { };
# else
# error No memory fence implementation for your platform!
# endif
#if LLVM_MULTITHREADED==0
return;
#else
# if defined(__GNUC__)
__sync_synchronize();
@ -42,7 +36,7 @@ namespace llvm {
#endif
}
#if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0
#if LLVM_MULTITHREADED==0
typedef unsigned long cas_flag;
template<typename T>
inline T CompareAndSwap(volatile T* dest,