Commit 2a5145b0 by Ian Lance Taylor Committed by Ian Lance Taylor

builtins.def (ATTR_NOTHROWCALL_LEAF_LIST): Define.

gcc/:
	* builtins.def (ATTR_NOTHROWCALL_LEAF_LIST): Define.
	* sync-builtins.def: Use ATTR_NOTHROWCALL_LEAF_LIST for all sync
	builtins that take pointers.
	* lto-opts.c (lto_write_options): Write -fnon-call-exceptions
	if set.
	* lto-wrapper.c (merge_and_complain): Collect
	OPT_fnon_call_exceptions.
	(run_gcc): Pass -fnon-call-exceptions.
gcc/testsuite/:
	* g++.dg/ext/sync-4.C: New test.

From-SVN: r204360
parent b96d19ff
2013-11-04 Ian Lance Taylor <iant@google.com>
* builtins.def (ATTR_NOTHROWCALL_LEAF_LIST): Define.
* sync-builtins.def: Use ATTR_NOTHROWCALL_LEAF_LIST for all sync
builtins that take pointers.
* lto-opts.c (lto_write_options): Write -fnon-call-exceptions
if set.
* lto-wrapper.c (merge_and_complain): Collect
OPT_fnon_call_exceptions.
(run_gcc): Pass -fnon-call-exceptions.
2013-11-04 Jakub Jelinek <jakub@redhat.com> 2013-11-04 Jakub Jelinek <jakub@redhat.com>
* optabs.c (expand_vec_perm): Revert one incorrect line from * optabs.c (expand_vec_perm): Revert one incorrect line from
...@@ -213,6 +213,12 @@ along with GCC; see the file COPYING3. If not see ...@@ -213,6 +213,12 @@ along with GCC; see the file COPYING3. If not see
#undef ATTR_MATHFN_FPROUNDING_STORE #undef ATTR_MATHFN_FPROUNDING_STORE
#define ATTR_MATHFN_FPROUNDING_STORE ATTR_NOTHROW_LEAF_LIST #define ATTR_MATHFN_FPROUNDING_STORE ATTR_NOTHROW_LEAF_LIST
/* Define an attribute list for leaf functions that do not throw
exceptions normally, but may throw exceptions when using
-fnon-call-exceptions. */
#define ATTR_NOTHROWCALL_LEAF_LIST (flag_non_call_exceptions ? \
ATTR_LEAF_LIST : ATTR_NOTHROW_LEAF_LIST)
/* Make sure 0 is not a legitimate builtin. */ /* Make sure 0 is not a legitimate builtin. */
DEF_BUILTIN_STUB(BUILT_IN_NONE, (const char *)0) DEF_BUILTIN_STUB(BUILT_IN_NONE, (const char *)0)
......
...@@ -77,7 +77,7 @@ lto_write_options (void) ...@@ -77,7 +77,7 @@ lto_write_options (void)
obstack_init (&temporary_obstack); obstack_init (&temporary_obstack);
/* Output options that affect GIMPLE IL semantics and are implicitely /* Output options that affect GIMPLE IL semantics and are implicitly
enabled by the frontend. enabled by the frontend.
This for now includes an explicit set of options that we also handle This for now includes an explicit set of options that we also handle
explicitly in lto-wrapper.c. In the end the effects on GIMPLE IL explicitly in lto-wrapper.c. In the end the effects on GIMPLE IL
...@@ -88,8 +88,13 @@ lto_write_options (void) ...@@ -88,8 +88,13 @@ lto_write_options (void)
if (global_options.x_flag_exceptions) if (global_options.x_flag_exceptions)
append_to_collect_gcc_options (&temporary_obstack, &first_p, append_to_collect_gcc_options (&temporary_obstack, &first_p,
"-fexceptions"); "-fexceptions");
/* -fnon-call-exceptions changes the generation of exception
regions. It is enabled implicitly by the Go frontend. */
if (global_options.x_flag_non_call_exceptions)
append_to_collect_gcc_options (&temporary_obstack, &first_p,
"-fnon-call-exceptions");
/* Output explicitely passed options. */ /* Output explicitly passed options. */
for (i = 1; i < save_decoded_options_count; ++i) for (i = 1; i < save_decoded_options_count; ++i)
{ {
struct cl_decoded_option *option = &save_decoded_options[i]; struct cl_decoded_option *option = &save_decoded_options[i];
......
...@@ -409,6 +409,7 @@ merge_and_complain (struct cl_decoded_option **decoded_options, ...@@ -409,6 +409,7 @@ merge_and_complain (struct cl_decoded_option **decoded_options,
case OPT_fpie: case OPT_fpie:
case OPT_fcommon: case OPT_fcommon:
case OPT_fexceptions: case OPT_fexceptions:
case OPT_fnon_call_exceptions:
case OPT_fgnu_tm: case OPT_fgnu_tm:
/* Do what the old LTO code did - collect exactly one option /* Do what the old LTO code did - collect exactly one option
setting per OPT code, we pick the first we encounter. setting per OPT code, we pick the first we encounter.
...@@ -573,6 +574,7 @@ run_gcc (unsigned argc, char *argv[]) ...@@ -573,6 +574,7 @@ run_gcc (unsigned argc, char *argv[])
case OPT_fpie: case OPT_fpie:
case OPT_fcommon: case OPT_fcommon:
case OPT_fexceptions: case OPT_fexceptions:
case OPT_fnon_call_exceptions:
case OPT_fgnu_tm: case OPT_fgnu_tm:
case OPT_freg_struct_return: case OPT_freg_struct_return:
case OPT_fpcc_struct_return: case OPT_fpcc_struct_return:
......
2013-11-04 Ian Lance Taylor <iant@google.com>
* g++.dg/ext/sync-4.C: New test.
2013-11-04 Paul Thomas <pault@gcc.gnu.org> 2013-11-04 Paul Thomas <pault@gcc.gnu.org>
PR fortran/58771 PR fortran/58771
......
/* { dg-do run { target hppa*-*-hpux* *-*-linux* *-*-gnu* powerpc*-*-darwin* *-*-darwin[912]* } } */
/* { dg-options "-fexceptions -fnon-call-exceptions -O2" } */
/* Verify that the builtin functions are correctly marked as trapping
when using -fnon-call-exceptions. */
#include <stdlib.h>
#include <signal.h>
typedef int int32_t __attribute__ ((mode (SI)));
typedef int int64_t __attribute__ ((mode (DI)));
#define FN(IDX, RET, CALL) \
static RET f ## IDX (void *p) __attribute__ ((noinline)); \
static RET \
f ## IDX (void *p) \
{ \
return CALL; \
} \
static void \
t ## IDX () \
{ \
try \
{ \
f ## IDX(0); \
} \
catch (...) \
{ \
return; \
} \
abort(); \
}
FN(1, int64_t, (__sync_fetch_and_add((int64_t*)p, 1)))
FN(2, int64_t, (__sync_fetch_and_sub((int64_t*)p, 1)))
FN(3, int64_t, (__sync_fetch_and_or((int64_t*)p, 1)))
FN(4, int64_t, (__sync_fetch_and_and((int64_t*)p, 1)))
FN(5, int64_t, (__sync_fetch_and_xor((int64_t*)p, 1)))
FN(6, int64_t, (__sync_fetch_and_nand((int64_t*)p, 1)))
FN( 7, int64_t, (__sync_add_and_fetch((int64_t*)p, 1)))
FN( 8, int64_t, (__sync_sub_and_fetch((int64_t*)p, 1)))
FN( 9, int64_t, (__sync_or_and_fetch((int64_t*)p, 1)))
FN(10, int64_t, (__sync_and_and_fetch((int64_t*)p, 1)))
FN(11, int64_t, (__sync_xor_and_fetch((int64_t*)p, 1)))
FN(12, int64_t, (__sync_nand_and_fetch((int64_t*)p, 1)))
FN(13, bool, (__sync_bool_compare_and_swap((int64_t*)p, 1, 2)))
FN(14, int64_t, (__sync_val_compare_and_swap((int64_t*)p, 1, 2)))
FN(15, int64_t, (__sync_lock_test_and_set((int64_t*)p, 1)))
FN(16, void, (__sync_lock_release((int64_t*)p)))
FN(17, bool, (__atomic_test_and_set((int64_t*)p, __ATOMIC_SEQ_CST)))
FN(18, void, (__atomic_clear((int64_t*)p, __ATOMIC_SEQ_CST)))
FN(19, void, (__atomic_exchange((int64_t*)p, (int64_t*)0, (int64_t*)0, __ATOMIC_SEQ_CST)))
FN(20, int64_t, (__atomic_exchange_n((int64_t*)p, 1, 2)))
FN(21, void, (__atomic_load((int64_t*)p, (int64_t*)0, __ATOMIC_SEQ_CST)))
FN(22, int64_t, (__atomic_load_n((int64_t*)p, __ATOMIC_SEQ_CST)))
FN(23, bool, (__atomic_compare_exchange((int64_t*)p, (int64_t*)0, (int64_t*)0, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)))
FN(24, bool, (__atomic_compare_exchange_n((int64_t*)p, (int64_t*)0, 1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)))
FN(25, void, (__atomic_store((int64_t*)p, (int64_t*)0, __ATOMIC_SEQ_CST)))
FN(26, void, (__atomic_store_n((int64_t*)p, 1, __ATOMIC_SEQ_CST)))
FN(27, int64_t, (__atomic_add_fetch((int64_t*)p, 1, __ATOMIC_SEQ_CST)))
FN(28, int64_t, (__atomic_sub_fetch((int64_t*)p, 1, __ATOMIC_SEQ_CST)))
FN(29, int64_t, (__atomic_and_fetch((int64_t*)p, 1, __ATOMIC_SEQ_CST)))
FN(30, int64_t, (__atomic_nand_fetch((int64_t*)p, 1, __ATOMIC_SEQ_CST)))
FN(31, int64_t, (__atomic_xor_fetch((int64_t*)p, 1, __ATOMIC_SEQ_CST)))
FN(32, int64_t, (__atomic_or_fetch((int64_t*)p, 1, __ATOMIC_SEQ_CST)))
FN(33, int64_t, (__atomic_fetch_add((int64_t*)p, 1, __ATOMIC_SEQ_CST)))
FN(34, int64_t, (__atomic_fetch_sub((int64_t*)p, 1, __ATOMIC_SEQ_CST)))
FN(35, int64_t, (__atomic_fetch_and((int64_t*)p, 1, __ATOMIC_SEQ_CST)))
FN(36, int64_t, (__atomic_fetch_nand((int64_t*)p, 1, __ATOMIC_SEQ_CST)))
FN(37, int64_t, (__atomic_fetch_xor((int64_t*)p, 1, __ATOMIC_SEQ_CST)))
FN(38, int64_t, (__atomic_fetch_or((int64_t*)p, 1, __ATOMIC_SEQ_CST)))
static void
handler(int)
{
sigset_t clear;
sigfillset (&clear);
sigprocmask (SIG_UNBLOCK, &clear, NULL);
throw 0;
}
int
main ()
{
signal (SIGSEGV, handler);
signal (SIGBUS, handler);
t1();
t2();
t3();
t4();
t5();
t6();
t7();
t8();
t9();
t10();
t11();
t12();
t13();
t14();
t15();
t16();
t17();
t18();
t19();
t20();
exit(0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment