[gcc/devel/ranger] Do not put incomplete CONSTRUCTORs into static memory
Aldy Hernandez
aldyh@gcc.gnu.org
Wed Jun 17 21:01:31 GMT 2020
https://gcc.gnu.org/g:2badc9885330b56dfabb49328c42de792bc67b1e
commit 2badc9885330b56dfabb49328c42de792bc67b1e
Author: Eric Botcazou <ebotcazou@gcc.gnu.org>
Date: Tue May 5 12:31:26 2020 +0200
Do not put incomplete CONSTRUCTORs into static memory
The CONSTRUCTOR_NO_CLEARING flag was invented to avoid generating a memset
for CONSTRUCTORS that lack elements, but it turns out that the gimplifier
can generate a memcpy for them instead, which is worse performance-wise,
so this prevents it from doing that for them.
* gimplify.c (gimplify_init_constructor): Do not put the constructor
into static memory if it is not complete.
Diff:
---
gcc/ChangeLog | 5 +++++
gcc/gimplify.c | 2 +-
gcc/testsuite/ChangeLog | 4 ++++
gcc/testsuite/gnat.dg/aggr29.adb | 12 ++++++++++++
4 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2267a63bca1..73634780e0f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2020-05-05 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gimplify.c (gimplify_init_constructor): Do not put the constructor
+ into static memory if it is not complete.
+
2020-05-05 Richard Biener <rguenther@suse.de>
PR tree-optimization/94949
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 2f2c51b2d89..7807e30fb2e 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -4995,8 +4995,8 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
all-zero initializers (which aren't big enough to merit
clearing), and don't try to make bitwise copies of
TREE_ADDRESSABLE types. */
-
if (valid_const_initializer
+ && complete_p
&& !(cleared || num_nonzero_elements == 0)
&& !TREE_ADDRESSABLE (type))
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2ffa0f8f434..7f973949a7f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2020-05-05 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/aggr29.adb: New test.
+
2020-05-05 Richard Biener <rguenther@suse.de>
PR tree-optimization/94949
diff --git a/gcc/testsuite/gnat.dg/aggr29.adb b/gcc/testsuite/gnat.dg/aggr29.adb
new file mode 100644
index 00000000000..c82a6f4c768
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/aggr29.adb
@@ -0,0 +1,12 @@
+-- { dg-do compile }
+-- { dg-options "-fdump-tree-gimple" }
+
+with Ada.Streams; use Ada.Streams;
+
+procedure Aggr29 is
+ A : aliased Stream_Element_Array := (1 .. 512 => <>);
+begin
+ null;
+end;
+
+-- { dg-final { scan-tree-dump-not "a___UNC = \\*" "gimple" } }
More information about the Gcc-cvs
mailing list