From 8673b6713e9457187cc9ecbefe949fb2393cb057 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Wed, 14 Jan 2015 13:58:35 +0000 Subject: [PATCH] re PR middle-end/59448 (Code generation doesn't respect C11 address-dependency) 2015-01-14 Andrew MacLeod PR middle-end/59448 * builtins.c (get_memmodel): Promote consume to acquire always. * testsuite/gcc.dg/atomic-invalid.c: Remove obselete test for illegal consume in an atomic_exchange. From-SVN: r219601 --- gcc/ChangeLog | 5 +++++ gcc/builtins.c | 5 +++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.dg/atomic-invalid.c | 2 -- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 43d6a1a0a93..a8dc1d36f74 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-01-14 Andrew MacLeod + + PR middle-end/59448 + * builtins.c (get_memmodel): Promote consume to acquire always. + 2014-01-14 Ilya Tocar PR target/64386 diff --git a/gcc/builtins.c b/gcc/builtins.c index 9280704e043..c8b1940e10a 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -5365,6 +5365,11 @@ get_memmodel (tree exp) return MEMMODEL_SEQ_CST; } + /* Workaround for Bugzilla 59448. GCC doesn't track consume properly, so + be conservative and promote consume to acquire. */ + if (val == MEMMODEL_CONSUME) + val = MEMMODEL_ACQUIRE; + return (enum memmodel) val; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d39b2d7814e..3df2a2c7185 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-01-14 Andrew MacLeod + + PR middle-end/59448 + * gcc.dg/atomic-invalid.c: Remove obselete test for illegal consume in + an atomic_exchange. + 2014-01-14 Ilya Tocar PR target/64386 diff --git a/gcc/testsuite/gcc.dg/atomic-invalid.c b/gcc/testsuite/gcc.dg/atomic-invalid.c index 4d040e1d572..6404ae86f5b 100644 --- a/gcc/testsuite/gcc.dg/atomic-invalid.c +++ b/gcc/testsuite/gcc.dg/atomic-invalid.c @@ -17,8 +17,6 @@ main () __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_exchange_n (&i, 1, __ATOMIC_CONSUME); /* { dg-error "invalid memory model" } */ - __atomic_load_n (&i, __ATOMIC_RELEASE); /* { dg-error "invalid memory model" } */ __atomic_load_n (&i, __ATOMIC_ACQ_REL); /* { dg-error "invalid memory model" } */ -- 2.30.2