]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end/94479 - fix gimplification of address
authorRichard Biener <rguenther@suse.de>
Tue, 7 Apr 2020 14:29:37 +0000 (16:29 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 7 Apr 2020 17:22:14 +0000 (19:22 +0200)
When gimplifying an address operand we may expose an indirect
ref via DECL_VALUE_EXPR for example.  This is dealt with in the
code already but it fails to consider that INDIRECT_REFs get
gimplified to MEM_REFs.

Fixed which makes the ICE observed on x86_64-netbsd go away.

2020-04-07  Richard Biener  <rguenther@suse.de>

PR middle-end/94479
* gimplify.c (gimplify_addr_expr): Also consider generated
MEM_REFs.

* gcc.dg/torture/pr94479.c: New testcase.

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr94479.c [new file with mode: 0644]

index 8c5e197591b38782148a3cc96f26f2edf3797b68..a1ab9fb4ef3c6e38ad2bb378f11ebf075dce9826 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-07  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/94479
+       * gimplify.c (gimplify_addr_expr): Also consider generated
+       MEM_REFs.
+
 2020-04-07  Andre Vieira  <andre.simoesdiasvieira@arm.com>
 
        * config/arm/arm_mve.h: Add C++ polymorphism and fix preserve MACROs.
index 787435c38cd6dae51734e8f2b360fbc6df00f891..8cdfae26510710b238f9be4536b0d90f22937911 100644 (file)
@@ -6181,7 +6181,9 @@ gimplify_addr_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 
       /* For various reasons, the gimplification of the expression
         may have made a new INDIRECT_REF.  */
-      if (TREE_CODE (op0) == INDIRECT_REF)
+      if (TREE_CODE (op0) == INDIRECT_REF
+         || (TREE_CODE (op0) == MEM_REF
+             && integer_zerop (TREE_OPERAND (op0, 1))))
        goto do_indirect_ref;
 
       mark_addressable (TREE_OPERAND (expr, 0));
index 096cfce891eaf10a1d1b65b9cca165eb069a1b36..71b5a14bcbe57b2d01084560a49b42f1ab0345f9 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-07  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/94479
+       * gcc.dg/torture/pr94479.c: New testcase.
+
 2020-04-01  Fritz Reese  <foreese@gcc.gnu.org>
 
         PR fortran/93871
diff --git a/gcc/testsuite/gcc.dg/torture/pr94479.c b/gcc/testsuite/gcc.dg/torture/pr94479.c
new file mode 100644 (file)
index 0000000..53285bb
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-require-stack-check "specific" } */
+/* { dg-additional-options "-fstack-check -w" } */
+
+int a;
+struct b {
+    char c;
+    void *d;  
+};
+struct b e() {
+    struct b f[] = {{}, "", f, a};
+}