]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR other/44038 (ICE: verify_stmts failed)
authorRichard Guenther <rguenther@suse.de>
Sat, 15 May 2010 15:06:47 +0000 (15:06 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Sat, 15 May 2010 15:06:47 +0000 (15:06 +0000)
2010-05-15  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/44038
* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Avoid
taking the address of a V_C_E of a constant.

* gcc.c-torture/compile/pr44038.c: New testcase.

From-SVN: r159434

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr44038.c [new file with mode: 0644]
gcc/tree-ssa-forwprop.c

index 222101556358d03a6edaa33da2fbc36343fdd618..5829fad17943cd820657f6924b195e3a5eb704cc 100644 (file)
@@ -1,3 +1,9 @@
+2010-05-15  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/44038
+       * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Avoid
+       taking the address of a V_C_E of a constant.
+
 2010-05-14  Jan Hubicka  <jh@suse.cz>
 
        * tree.h (memory_identifier_string): Remove.
index 32b066e0d9a314f6ca734143341d2e9391a34886..3223474115a26abe0454e1fd1ceb80f0668919ee 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-15  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/44038
+       * gcc.c-torture/compile/pr44038.c: New testcase.
+
 2010-05-15  H.J. Lu  <hongjiu.lu@intel.com>
 
        * gcc.target/i386/avx-cmpsd-1.c: Add -std=c99.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44038.c b/gcc/testsuite/gcc.c-torture/compile/pr44038.c
new file mode 100644 (file)
index 0000000..574ff39
--- /dev/null
@@ -0,0 +1,13 @@
+struct Ustr {
+    char data[1]; 
+};
+int ustr_xi__embed_val_get(char *);
+inline static int ustr_len(struct Ustr *s1)
+{
+  return ustr_xi__embed_val_get(s1->data);
+}
+static struct Ustr *s1 = ((struct Ustr *) "");
+int tst(char *cstr)
+{
+  return ustr_len(s1);
+}
index fc40bf46eac26d42547cfe88ceb9de5e73d09e9a..836ca7c1aa8fbfe8cea55ed1a921e3d2489651f8 100644 (file)
@@ -730,6 +730,7 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
   gimple use_stmt = gsi_stmt (*use_stmt_gsi);
   enum tree_code rhs_code;
   bool res = true;
+  bool addr_p = false;
 
   gcc_assert (TREE_CODE (def_rhs) == ADDR_EXPR);
 
@@ -802,8 +803,12 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
   /* Strip away any outer COMPONENT_REF, ARRAY_REF or ADDR_EXPR
      nodes from the RHS.  */
   rhsp = gimple_assign_rhs1_ptr (use_stmt);
-  while (handled_component_p (*rhsp)
-        || TREE_CODE (*rhsp) == ADDR_EXPR)
+  if (TREE_CODE (*rhsp) == ADDR_EXPR)
+    {
+      rhsp = &TREE_OPERAND (*rhsp, 0);
+      addr_p = true;
+    }
+  while (handled_component_p (*rhsp))
     rhsp = &TREE_OPERAND (*rhsp, 0);
   rhs = *rhsp;
 
@@ -852,11 +857,14 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
         return res;
        }
      /* If the defining rhs comes from an indirect reference, then do not
-        convert into a VIEW_CONVERT_EXPR.  */
+        convert into a VIEW_CONVERT_EXPR.  Likewise if we'll end up taking
+       the address of a V_C_E of a constant.  */
      def_rhs_base = TREE_OPERAND (def_rhs, 0);
      while (handled_component_p (def_rhs_base))
        def_rhs_base = TREE_OPERAND (def_rhs_base, 0);
-     if (!INDIRECT_REF_P (def_rhs_base))
+     if (!INDIRECT_REF_P (def_rhs_base)
+        && (!addr_p
+            || !is_gimple_min_invariant (def_rhs)))
        {
         /* We may have arbitrary VIEW_CONVERT_EXPRs in a nested component
            reference.  Place it there and fold the thing.  */