builtins.c (expand_builtin_atomic_exchange): Remove error when memory model is CONSUME.
authorAndrew MacLeod <amacleod@redhat.com>
Wed, 14 Jan 2015 21:30:39 +0000 (21:30 +0000)
committerAndrew Macleod <amacleod@gcc.gnu.org>
Wed, 14 Jan 2015 21:30:39 +0000 (21:30 +0000)
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.
* 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
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/atomic-invalid.c

index f0bd2df..9c4c83b 100644 (file)
@@ -1,3 +1,13 @@
+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
index c8b1940..23d183a 100644 (file)
@@ -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)
index 9b24631..644aa86 100644 (file)
@@ -1,3 +1,9 @@
+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
index 6404ae8..f2adcdf 100644 (file)
@@ -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" } */
 
 }