public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/autopar_devel] expr: Unbreak build of mesa [PR96194]
@ 2020-08-22 23:38 Giuliano Belinassi
  0 siblings, 0 replies; only message in thread
From: Giuliano Belinassi @ 2020-08-22 23:38 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d461329292f5cc9adcc5e3804016389452dbc21b

commit d461329292f5cc9adcc5e3804016389452dbc21b
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Jul 14 16:01:11 2020 +0200

    expr: Unbreak build of mesa [PR96194]
    
    > > The store to the whole of each volatile object was picked apart
    > > like there had been an individual assignment to each of the
    > > fields.  Reads were added as part of that; see PR for details.
    > > The reads from volatile memory were a clear bug; individual
    > > stores questionable.  A separate patch clarifies the docs.
    
    This breaks building of mesa on both the trunk and 10 branch.
    
    The problem is that the middle-end may never create temporaries of non-POD
    (TREE_ADDRESSABLE) types, those can be only created when the language says
    so and thus only the FE is allowed to create those.
    
    This patch just reverts the behavior to what we used to do before for the
    stores to volatile non-PODs.  Perhaps we want to do something else, but
    definitely we can't create temporaries of the non-POD type.  It is up to
    discussions on what should happen in those cases.
    
    2020-07-14  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/96194
            * expr.c (expand_constructor): Don't create temporary for store to
            volatile MEM if exp has an addressable type.
    
            * g++.dg/opt/pr96194.C: New test.

Diff:
---
 gcc/expr.c                         |  4 +++-
 gcc/testsuite/g++.dg/opt/pr96194.C | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/gcc/expr.c b/gcc/expr.c
index 3d205ad3506..edc5571ba00 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -8382,7 +8382,9 @@ expand_constructor (tree exp, rtx target, enum expand_modifier modifier,
       || GET_CODE (target) == PARALLEL || modifier == EXPAND_STACK_PARM
       /* Also make a temporary if the store is to volatile memory, to
 	 avoid individual accesses to aggregate members.  */
-      || (GET_CODE (target) == MEM && MEM_VOLATILE_P (target)))
+      || (GET_CODE (target) == MEM
+	  && MEM_VOLATILE_P (target)
+	  && !TREE_ADDRESSABLE (TREE_TYPE (exp))))
     {
       if (avoid_temp_mem)
 	return NULL_RTX;
diff --git a/gcc/testsuite/g++.dg/opt/pr96194.C b/gcc/testsuite/g++.dg/opt/pr96194.C
new file mode 100644
index 00000000000..749be2a2322
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr96194.C
@@ -0,0 +1,21 @@
+// PR middle-end/96194
+// { dg-do compile }
+// { dg-options "-O2" }
+
+#include <new>
+
+struct A { ~A (); };
+struct B : A { float e[64]; };
+
+B *
+foo ()
+{
+  return new ((void *) 0) B ();
+}
+
+B *
+bar (void *x, bool y)
+{
+  void *p = y ? x : (void *) 0;
+  return new (p) B ();
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-22 23:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 23:38 [gcc/devel/autopar_devel] expr: Unbreak build of mesa [PR96194] Giuliano Belinassi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).