From 77df532784a1cf843a87c932b49e3062c5e84de5 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Wed, 14 Jan 2015 21:30:39 +0000 Subject: [PATCH] builtins.c (expand_builtin_atomic_exchange): Remove error when memory model is CONSUME. 2015-01-14 Andrew MacLeod * builtins.c (expand_builtin_atomic_exchange): Remove error when memory model is CONSUME. (expand_builtin_atomic_compare_exchange, expand_builtin_atomic_load, expand_builtin_atomic_store): Change invalid memory model errors to warnings. (expand_builtin_atomic_clear): Change invalid model errors to warnings and issue warning for CONSUME. * testsuite/gcc.dg/atomic-invalid.c: Check for invalid memory model warnings instead of errors. M gcc/ChangeLog M gcc/builtins.c M gcc/testsuite/ChangeLog M gcc/testsuite/gcc.dg/atomic-invalid.c From-SVN: r219615 --- gcc/ChangeLog | 10 ++++++ gcc/builtins.c | 46 +++++++++++++++------------ gcc/testsuite/ChangeLog | 6 ++++ gcc/testsuite/gcc.dg/atomic-invalid.c | 21 ++++++------ 4 files changed, 52 insertions(+), 31 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f0bd2dfae79..9c4c83b3638 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2015-01-14 Andrew MacLeod + + * builtins.c (expand_builtin_atomic_exchange): Remove error when + memory model is CONSUME. + (expand_builtin_atomic_compare_exchange, expand_builtin_atomic_load, + expand_builtin_atomic_store): Change invalid memory model errors to + warnings. + (expand_builtin_atomic_clear): Change invalid model errors to warnings + and issue warning for CONSUME. + 2015-01-14 Aldy Hernandez * lto-cgraph: Update function comments for diff --git a/gcc/builtins.c b/gcc/builtins.c index c8b1940e10a..23d183a1c25 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -5385,11 +5385,6 @@ expand_builtin_atomic_exchange (machine_mode mode, tree exp, rtx target) enum memmodel model; model = get_memmodel (CALL_EXPR_ARG (exp, 2)); - if ((model & MEMMODEL_MASK) == MEMMODEL_CONSUME) - { - error ("invalid memory model for %<__atomic_exchange%>"); - return NULL_RTX; - } if (!flag_inline_atomics) return NULL_RTX; @@ -5422,20 +5417,25 @@ expand_builtin_atomic_compare_exchange (machine_mode mode, tree exp, success = get_memmodel (CALL_EXPR_ARG (exp, 4)); failure = get_memmodel (CALL_EXPR_ARG (exp, 5)); + if (failure > success) + { + warning (OPT_Winvalid_memory_model, + "failure memory model cannot be stronger than success memory " + "model for %<__atomic_compare_exchange%>"); + success = MEMMODEL_SEQ_CST; + } + if ((failure & MEMMODEL_MASK) == MEMMODEL_RELEASE || (failure & MEMMODEL_MASK) == MEMMODEL_ACQ_REL) { - error ("invalid failure memory model for %<__atomic_compare_exchange%>"); - return NULL_RTX; + warning (OPT_Winvalid_memory_model, + "invalid failure memory model for " + "%<__atomic_compare_exchange%>"); + failure = MEMMODEL_SEQ_CST; + success = MEMMODEL_SEQ_CST; } - if (failure > success) - { - error ("failure memory model cannot be stronger than success " - "memory model for %<__atomic_compare_exchange%>"); - return NULL_RTX; - } - + if (!flag_inline_atomics) return NULL_RTX; @@ -5491,8 +5491,9 @@ expand_builtin_atomic_load (machine_mode mode, tree exp, rtx target) if ((model & MEMMODEL_MASK) == MEMMODEL_RELEASE || (model & MEMMODEL_MASK) == MEMMODEL_ACQ_REL) { - error ("invalid memory model for %<__atomic_load%>"); - return NULL_RTX; + warning (OPT_Winvalid_memory_model, + "invalid memory model for %<__atomic_load%>"); + model = MEMMODEL_SEQ_CST; } if (!flag_inline_atomics) @@ -5521,8 +5522,9 @@ expand_builtin_atomic_store (machine_mode mode, tree exp) && (model & MEMMODEL_MASK) != MEMMODEL_SEQ_CST && (model & MEMMODEL_MASK) != MEMMODEL_RELEASE) { - error ("invalid memory model for %<__atomic_store%>"); - return NULL_RTX; + warning (OPT_Winvalid_memory_model, + "invalid memory model for %<__atomic_store%>"); + model = MEMMODEL_SEQ_CST; } if (!flag_inline_atomics) @@ -5625,11 +5627,13 @@ expand_builtin_atomic_clear (tree exp) mem = get_builtin_sync_mem (CALL_EXPR_ARG (exp, 0), mode); model = get_memmodel (CALL_EXPR_ARG (exp, 1)); - if ((model & MEMMODEL_MASK) == MEMMODEL_ACQUIRE + if ((model & MEMMODEL_MASK) == MEMMODEL_CONSUME + || (model & MEMMODEL_MASK) == MEMMODEL_ACQUIRE || (model & MEMMODEL_MASK) == MEMMODEL_ACQ_REL) { - error ("invalid memory model for %<__atomic_store%>"); - return const0_rtx; + warning (OPT_Winvalid_memory_model, + "invalid memory model for %<__atomic_store%>"); + model = MEMMODEL_SEQ_CST; } if (HAVE_atomic_clear) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9b24631a209..644aa862975 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-01-14 Andrew MacLeod + + * gcc.dg/atomic-invalid.c: Check for invalid memory model + warnings instead of errors. + + 2015-01-14 Ilya Verbin * lib/target-supports.exp (check_effective_target_lto): Check for -flto diff --git a/gcc/testsuite/gcc.dg/atomic-invalid.c b/gcc/testsuite/gcc.dg/atomic-invalid.c index 6404ae86f5b..f2adcdfbfa8 100644 --- a/gcc/testsuite/gcc.dg/atomic-invalid.c +++ b/gcc/testsuite/gcc.dg/atomic-invalid.c @@ -13,23 +13,24 @@ bool x; int main () { - __atomic_compare_exchange_n (&i, &e, 1, 0, __ATOMIC_RELAXED, __ATOMIC_SEQ_CST); /* { dg-error "failure memory model cannot be stronger" } */ - __atomic_compare_exchange_n (&i, &e, 1, 0, __ATOMIC_SEQ_CST, __ATOMIC_RELEASE); /* { dg-error "invalid failure memory" } */ - __atomic_compare_exchange_n (&i, &e, 1, 1, __ATOMIC_SEQ_CST, __ATOMIC_ACQ_REL); /* { dg-error "invalid failure memory" } */ + __atomic_compare_exchange_n (&i, &e, 1, 0, __ATOMIC_RELAXED, __ATOMIC_SEQ_CST); /* { dg-warning "failure memory model cannot be stronger" } */ + __atomic_compare_exchange_n (&i, &e, 1, 0, __ATOMIC_SEQ_CST, __ATOMIC_RELEASE); /* { dg-warning "invalid failure memory" } */ + __atomic_compare_exchange_n (&i, &e, 1, 1, __ATOMIC_SEQ_CST, __ATOMIC_ACQ_REL); /* { dg-warning "invalid failure memory" } */ - __atomic_load_n (&i, __ATOMIC_RELEASE); /* { dg-error "invalid memory model" } */ - __atomic_load_n (&i, __ATOMIC_ACQ_REL); /* { dg-error "invalid memory model" } */ + __atomic_load_n (&i, __ATOMIC_RELEASE); /* { dg-warning "invalid memory model" } */ + __atomic_load_n (&i, __ATOMIC_ACQ_REL); /* { dg-warning "invalid memory model" } */ - __atomic_store_n (&i, 1, __ATOMIC_ACQUIRE); /* { dg-error "invalid memory model" } */ - __atomic_store_n (&i, 1, __ATOMIC_CONSUME); /* { dg-error "invalid memory model" } */ - __atomic_store_n (&i, 1, __ATOMIC_ACQ_REL); /* { dg-error "invalid memory model" } */ + __atomic_store_n (&i, 1, __ATOMIC_ACQUIRE); /* { dg-warning "invalid memory model" } */ + __atomic_store_n (&i, 1, __ATOMIC_CONSUME); /* { dg-warning "invalid memory model" } */ + __atomic_store_n (&i, 1, __ATOMIC_ACQ_REL); /* { dg-warning "invalid memory model" } */ i = __atomic_always_lock_free (s, NULL); /* { dg-error "non-constant argument" } */ __atomic_load_n (&i, 44); /* { dg-warning "invalid memory model" } */ - __atomic_clear (&x, __ATOMIC_ACQUIRE); /* { dg-error "invalid memory model" } */ + __atomic_clear (&x, __ATOMIC_CONSUME); /* { dg-warning "invalid memory model" } */ + __atomic_clear (&x, __ATOMIC_ACQUIRE); /* { dg-warning "invalid memory model" } */ - __atomic_clear (&x, __ATOMIC_ACQ_REL); /* { dg-error "invalid memory model" } */ + __atomic_clear (&x, __ATOMIC_ACQ_REL); /* { dg-warning "invalid memory model" } */ } -- 2.30.2