From: Richard Henderson Date: Fri, 21 Feb 2014 00:11:43 +0000 (-0800) Subject: re PR c++/60272 (atomic<>::compare_exchange_weak has spurious store and can cause... X-Git-Tag: releases/gcc-4.9.0~794 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fdc29e8c7f95019aecdcbed5b556c82dbd91c7c;p=thirdparty%2Fgcc.git re PR c++/60272 (atomic<>::compare_exchange_weak has spurious store and can cause race conditions) PR c++/60272 * builtins.c (expand_builtin_atomic_compare_exchange): Always make a new pseudo for OLDVAL. From-SVN: r207972 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cbdecf83d202..c51d139850e1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-02-20 Richard Henderson + + PR c++/60272 + * builtins.c (expand_builtin_atomic_compare_exchange): Always make + a new pseudo for OLDVAL. + 2014-02-20 Jakub Jelinek PR target/57896 diff --git a/gcc/builtins.c b/gcc/builtins.c index 09fefe50a8d9..35969ad41844 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -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;