llvm.org GIT mirror llvm / a860370
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72140 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 11 years ago
3 changed file(s) with 68 addition(s) and 69 deletion(s). Raw diff Collapse all Expand all
371371 default) AC_SUBST(ENABLE_THREADS,[1]) ;;
372372 *) AC_MSG_ERROR([Invalid setting for --enable-threads. Use "yes" or "no"]) ;;
373373 esac
374 AC_DEFINE_UNQUOTED([ENABLE_THREADS],$ENABLE_THREADS,[Define if threads enabled])
374375
375376 dnl Allow building without position independent code
376377 AC_ARG_ENABLE(pic,
896897 fi
897898
898899 dnl atomic builtins are required for threading support.
899 if test "$ENABLE_THREADS" -eq 1 ; then
900 AC_MSG_CHECKING(for GCC atomic builtins)
901 AC_LINK_IFELSE(
902 AC_LANG_SOURCE(
903 [[int main() {
904 volatile unsigned long val = 1;
905 __sync_synchronize();
906 __sync_val_compare_and_swap(&val, 1, 0);
907 return 0;
908 }
909 ]]),
910 AC_MSG_RESULT(yes),
911 AC_MSG_RESULT(no)
912 AC_SUBST(ENABLE_THREADS, [0])
913 AC_MSG_WARN([Threading support disabled because atomic builtins are missing]))
914 fi
915
916 AC_DEFINE_UNQUOTED([ENABLE_THREADS],$ENABLE_THREADS,[Define if threads enabled])
900 AC_MSG_CHECKING(for GCC atomic builtins)
901 AC_LINK_IFELSE(
902 AC_LANG_SOURCE(
903 [[int main() {
904 volatile unsigned long val = 1;
905 __sync_synchronize();
906 __sync_val_compare_and_swap(&val, 1, 0);
907 return 0;
908 }
909 ]]),
910 AC_MSG_RESULT(yes)
911 AC_DEFINE(LLVM_MULTITHREADED, 1, Build multithreading support into LLVM),
912 AC_MSG_RESULT(no)
913 AC_DEFINE(LLVM_MULTITHREADED, 0, Build multithreading support into LLVM)
914 AC_MSG_WARN([LLVM will be built thread-unsafe because atomic builtins are missing]))
915
917916
918917 dnl===-----------------------------------------------------------------------===
919918 dnl===
48694869 { (exit 1); exit 1; }; } ;;
48704870 esac
48714871
4872 cat >>confdefs.h <<_ACEOF
4873 #define ENABLE_THREADS $ENABLE_THREADS
4874 _ACEOF
4875
4876
48724877 # Check whether --enable-pic was given.
48734878 if test "${enable_pic+set}" = set; then
48744879 enableval=$enable_pic;
1056910574 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1057010575 lt_status=$lt_dlunknown
1057110576 cat > conftest.$ac_ext <
10572 #line 10573 "configure"
10577 #line 10578 "configure"
1057310578 #include "confdefs.h"
1057410579
1057510580 #if HAVE_DLFCN_H
1271312718 ;;
1271412719 *-*-irix6*)
1271512720 # Find out which ABI we are using.
12716 echo '#line 12717 "configure"' > conftest.$ac_ext
12721 echo '#line 12722 "configure"' > conftest.$ac_ext
1271712722 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
1271812723 (eval $ac_compile) 2>&5
1271912724 ac_status=$?
1443114436 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1443214437 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1443314438 -e 's:$: $lt_compiler_flag:'`
14434 (eval echo "\"\$as_me:14435: $lt_compile\"" >&5)
14439 (eval echo "\"\$as_me:14440: $lt_compile\"" >&5)
1443514440 (eval "$lt_compile" 2>conftest.err)
1443614441 ac_status=$?
1443714442 cat conftest.err >&5
14438 echo "$as_me:14439: \$? = $ac_status" >&5
14443 echo "$as_me:14444: \$? = $ac_status" >&5
1443914444 if (exit $ac_status) && test -s "$ac_outfile"; then
1444014445 # The compiler can only warn and ignore the option if not recognized
1444114446 # So say no if there are warnings other than the usual output.
1469914704 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1470014705 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1470114706 -e 's:$: $lt_compiler_flag:'`
14702 (eval echo "\"\$as_me:14703: $lt_compile\"" >&5)
14707 (eval echo "\"\$as_me:14708: $lt_compile\"" >&5)
1470314708 (eval "$lt_compile" 2>conftest.err)
1470414709 ac_status=$?
1470514710 cat conftest.err >&5
14706 echo "$as_me:14707: \$? = $ac_status" >&5
14711 echo "$as_me:14712: \$? = $ac_status" >&5
1470714712 if (exit $ac_status) && test -s "$ac_outfile"; then
1470814713 # The compiler can only warn and ignore the option if not recognized
1470914714 # So say no if there are warnings other than the usual output.
1480314808 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1480414809 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1480514810 -e 's:$: $lt_compiler_flag:'`
14806 (eval echo "\"\$as_me:14807: $lt_compile\"" >&5)
14811 (eval echo "\"\$as_me:14812: $lt_compile\"" >&5)
1480714812 (eval "$lt_compile" 2>out/conftest.err)
1480814813 ac_status=$?
1480914814 cat out/conftest.err >&5
14810 echo "$as_me:14811: \$? = $ac_status" >&5
14815 echo "$as_me:14816: \$? = $ac_status" >&5
1481114816 if (exit $ac_status) && test -s out/conftest2.$ac_objext
1481214817 then
1481314818 # The compiler can only warn and ignore the option if not recognized
1725517260 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1725617261 lt_status=$lt_dlunknown
1725717262 cat > conftest.$ac_ext <
17258 #line 17259 "configure"
17263 #line 17264 "configure"
1725917264 #include "confdefs.h"
1726017265
1726117266 #if HAVE_DLFCN_H
1735517360 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1735617361 lt_status=$lt_dlunknown
1735717362 cat > conftest.$ac_ext <
17358 #line 17359 "configure"
17363 #line 17364 "configure"
1735917364 #include "confdefs.h"
1736017365
1736117366 #if HAVE_DLFCN_H
1972319728 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1972419729 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1972519730 -e 's:$: $lt_compiler_flag:'`
19726 (eval echo "\"\$as_me:19727: $lt_compile\"" >&5)
19731 (eval echo "\"\$as_me:19732: $lt_compile\"" >&5)
1972719732 (eval "$lt_compile" 2>conftest.err)
1972819733 ac_status=$?
1972919734 cat conftest.err >&5
19730 echo "$as_me:19731: \$? = $ac_status" >&5
19735 echo "$as_me:19736: \$? = $ac_status" >&5
1973119736 if (exit $ac_status) && test -s "$ac_outfile"; then
1973219737 # The compiler can only warn and ignore the option if not recognized
1973319738 # So say no if there are warnings other than the usual output.
1982719832 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1982819833 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1982919834 -e 's:$: $lt_compiler_flag:'`
19830 (eval echo "\"\$as_me:19831: $lt_compile\"" >&5)
19835 (eval echo "\"\$as_me:19836: $lt_compile\"" >&5)
1983119836 (eval "$lt_compile" 2>out/conftest.err)
1983219837 ac_status=$?
1983319838 cat out/conftest.err >&5
19834 echo "$as_me:19835: \$? = $ac_status" >&5
19839 echo "$as_me:19840: \$? = $ac_status" >&5
1983519840 if (exit $ac_status) && test -s out/conftest2.$ac_objext
1983619841 then
1983719842 # The compiler can only warn and ignore the option if not recognized
2139721402 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2139821403 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2139921404 -e 's:$: $lt_compiler_flag:'`
21400 (eval echo "\"\$as_me:21401: $lt_compile\"" >&5)
21405 (eval echo "\"\$as_me:21406: $lt_compile\"" >&5)
2140121406 (eval "$lt_compile" 2>conftest.err)
2140221407 ac_status=$?
2140321408 cat conftest.err >&5
21404 echo "$as_me:21405: \$? = $ac_status" >&5
21409 echo "$as_me:21410: \$? = $ac_status" >&5
2140521410 if (exit $ac_status) && test -s "$ac_outfile"; then
2140621411 # The compiler can only warn and ignore the option if not recognized
2140721412 # So say no if there are warnings other than the usual output.
2150121506 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2150221507 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2150321508 -e 's:$: $lt_compiler_flag:'`
21504 (eval echo "\"\$as_me:21505: $lt_compile\"" >&5)
21509 (eval echo "\"\$as_me:21510: $lt_compile\"" >&5)
2150521510 (eval "$lt_compile" 2>out/conftest.err)
2150621511 ac_status=$?
2150721512 cat out/conftest.err >&5
21508 echo "$as_me:21509: \$? = $ac_status" >&5
21513 echo "$as_me:21514: \$? = $ac_status" >&5
2150921514 if (exit $ac_status) && test -s out/conftest2.$ac_objext
2151021515 then
2151121516 # The compiler can only warn and ignore the option if not recognized
2373623741 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2373723742 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2373823743 -e 's:$: $lt_compiler_flag:'`
23739 (eval echo "\"\$as_me:23740: $lt_compile\"" >&5)
23744 (eval echo "\"\$as_me:23745: $lt_compile\"" >&5)
2374023745 (eval "$lt_compile" 2>conftest.err)
2374123746 ac_status=$?
2374223747 cat conftest.err >&5
23743 echo "$as_me:23744: \$? = $ac_status" >&5
23748 echo "$as_me:23749: \$? = $ac_status" >&5
2374423749 if (exit $ac_status) && test -s "$ac_outfile"; then
2374523750 # The compiler can only warn and ignore the option if not recognized
2374623751 # So say no if there are warnings other than the usual output.
2400424009 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2400524010 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2400624011 -e 's:$: $lt_compiler_flag:'`
24007 (eval echo "\"\$as_me:24008: $lt_compile\"" >&5)
24012 (eval echo "\"\$as_me:24013: $lt_compile\"" >&5)
2400824013 (eval "$lt_compile" 2>conftest.err)
2400924014 ac_status=$?
2401024015 cat conftest.err >&5
24011 echo "$as_me:24012: \$? = $ac_status" >&5
24016 echo "$as_me:24017: \$? = $ac_status" >&5
2401224017 if (exit $ac_status) && test -s "$ac_outfile"; then
2401324018 # The compiler can only warn and ignore the option if not recognized
2401424019 # So say no if there are warnings other than the usual output.
2410824113 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2410924114 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2411024115 -e 's:$: $lt_compiler_flag:'`
24111 (eval echo "\"\$as_me:24112: $lt_compile\"" >&5)
24116 (eval echo "\"\$as_me:24117: $lt_compile\"" >&5)
2411224117 (eval "$lt_compile" 2>out/conftest.err)
2411324118 ac_status=$?
2411424119 cat out/conftest.err >&5
24115 echo "$as_me:24116: \$? = $ac_status" >&5
24120 echo "$as_me:24121: \$? = $ac_status" >&5
2411624121 if (exit $ac_status) && test -s out/conftest2.$ac_objext
2411724122 then
2411824123 # The compiler can only warn and ignore the option if not recognized
3360133606 fi
3360233607 fi
3360333608
33604 if test "$ENABLE_THREADS" -eq 1 ; then
33605 { echo "$as_me:$LINENO: checking for GCC atomic builtins" >&5
33609 { echo "$as_me:$LINENO: checking for GCC atomic builtins" >&5
3360633610 echo $ECHO_N "checking for GCC atomic builtins... $ECHO_C" >&6; }
33607 cat >conftest.$ac_ext <<_ACEOF
33611 cat >conftest.$ac_ext <<_ACEOF
3360833612 /* confdefs.h. */
3360933613 _ACEOF
3361033614 cat confdefs.h >>conftest.$ac_ext
3361133615 cat >>conftest.$ac_ext <<_ACEOF
3361233616 /* end confdefs.h. */
3361333617 int main() {
33614 volatile unsigned long val = 1;
33615 __sync_synchronize();
33616 __sync_val_compare_and_swap(&val, 1, 0);
33617 return 0;
33618 }
33618 volatile unsigned long val = 1;
33619 __sync_synchronize();
33620 __sync_val_compare_and_swap(&val, 1, 0);
33621 return 0;
33622 }
3361933623
3362033624 _ACEOF
3362133625 rm -f conftest.$ac_objext conftest$ac_exeext
3365433658 (exit $ac_status); }; }; then
3365533659 { echo "$as_me:$LINENO: result: yes" >&5
3365633660 echo "${ECHO_T}yes" >&6; }
33661
33662 cat >>confdefs.h <<\_ACEOF
33663 #define LLVM_MULTITHREADED 1
33664 _ACEOF
33665
3365733666 else
3365833667 echo "$as_me: failed program was:" >&5
3365933668 sed 's/^/| /' conftest.$ac_ext >&5
3366033669
3366133670 { echo "$as_me:$LINENO: result: no" >&5
3366233671 echo "${ECHO_T}no" >&6; }
33663 ENABLE_THREADS=0
33664
33665 { echo "$as_me:$LINENO: WARNING: Threading support disabled because atomic builtins are missing" >&5
33666 echo "$as_me: WARNING: Threading support disabled because atomic builtins are missing" >&2;}
33672
33673 cat >>confdefs.h <<\_ACEOF
33674 #define LLVM_MULTITHREADED 0
33675 _ACEOF
33676
33677 { echo "$as_me:$LINENO: WARNING: LLVM will be built thread-unsafe because atomic builtins are missing" >&5
33678 echo "$as_me: WARNING: LLVM will be built thread-unsafe because atomic builtins are missing" >&2;}
3366733679 fi
3366833680
3366933681 rm -f core conftest.err conftest.$ac_objext \
3367033682 conftest$ac_exeext conftest.$ac_ext
33671 fi
33672
33673
33674 cat >>confdefs.h <<_ACEOF
33675 #define ENABLE_THREADS $ENABLE_THREADS
33676 _ACEOF
3367733683
3367833684
3367933685
2222 namespace sys {
2323
2424 inline void MemoryFence() {
25 #if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0
26 # if defined(__GNUC__)
27 __asm__ __volatile__("" : : : "memory");
28 # elif defined(_MSC_VER)
29 __asm { };
30 # else
31 # error No memory fence implementation for your platform!
32 # endif
25 #if LLVM_MULTITHREADED==0
26 return;
3327 #else
3428 # if defined(__GNUC__)
3529 __sync_synchronize();
4135 #endif
4236 }
4337
44 #if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0
38 #if LLVM_MULTITHREADED==0
4539 typedef unsigned long cas_flag;
4640 template
4741 inline T CompareAndSwap(volatile T* dest,