PR c++/60272
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Feb 2014 00:11:43 +0000 (00:11 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Feb 2014 00:11:43 +0000 (00:11 +0000)
        * builtins.c (expand_builtin_atomic_compare_exchange): Always make
        a new pseudo for OLDVAL.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207972 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/builtins.c

index cbdecf8..c51d139 100644 (file)
@@ -1,3 +1,9 @@
+2014-02-20  Richard Henderson  <rth@redhat.com>
+
+       PR c++/60272
+       * builtins.c (expand_builtin_atomic_compare_exchange): Always make
+       a new pseudo for OLDVAL.
+
 2014-02-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/57896
index 09fefe5..35969ad 100644 (file)
@@ -5332,9 +5332,12 @@ expand_builtin_atomic_compare_exchange (enum machine_mode mode, tree exp,
 
   if (target == const0_rtx)
     target = NULL;
-  oldval = expect;
 
-  if (!expand_atomic_compare_and_swap (&target, &oldval, mem, oldval, desired,
+  /* Lest the rtl backend create a race condition with an imporoper store
+     to memory, always create a new pseudo for OLDVAL.  */
+  oldval = NULL;
+
+  if (!expand_atomic_compare_and_swap (&target, &oldval, mem, expect, desired,
                                       is_weak, success, failure))
     return NULL_RTX;