+2015-01-14 Andrew MacLeod <amacleod@redhat.com>
+
+ * 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 <aldyh@redhat.com>
* lto-cgraph: Update function comments for
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;
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;
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)
&& (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)
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)
+2015-01-14 Andrew MacLeod <amacleod@redhat.com>
+
+ * gcc.dg/atomic-invalid.c: Check for invalid memory model
+ warnings instead of errors.
+
+
2015-01-14 Ilya Verbin <ilya.verbin@intel.com>
* lib/target-supports.exp (check_effective_target_lto): Check for -flto
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" } */
}