This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR39648 (maybe the various ICEs and bootstrap failures)


This works around the long-standing stupidity of the C frontend generating
ADDR_EXPRs with wrong types, &Array with pointer-to-element type instead
of &Array[0].  Seemingly folding *&Array to Array of course leads to
interesting effects if you start to insert expressions of that type in 
PRE.

Bootstrap & regtest running.  It would be nice if all the people that
reported bugs without preprocessed source would verify if the following
patch fixes their issues.

Thanks,
Richard.

2009-04-05  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/39648
	* tree-ssa-sccvn.c (vn_reference_fold_indirect): Work around
	our &A vs. &A[0] IL deficiencies.

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

Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c	(revision 145563)
--- gcc/tree-ssa-sccvn.c	(working copy)
*************** vn_reference_fold_indirect (VEC (vn_refe
*** 757,762 ****
--- 757,779 ----
  
    /* Get ops for the addressed object.  */
    op = VEC_index (vn_reference_op_s, *ops, i);
+   /* ???  If this is our usual typeof &ARRAY vs. &ARRAY[0] problem, work
+      around it to avoid later ICEs.  */
+   if (TREE_CODE (TREE_TYPE (TREE_OPERAND (op->op0, 0))) == ARRAY_TYPE
+       && TREE_CODE (TREE_TYPE (TREE_TYPE (op->op0))) != ARRAY_TYPE)
+     {
+       vn_reference_op_s aref;
+       tree dom;
+       aref.type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (op->op0)));
+       aref.opcode = ARRAY_REF;
+       aref.op0 = integer_zero_node;
+       if ((dom = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (op->op0, 0))))
+ 	  && TYPE_MIN_VALUE (dom))
+ 	aref.op0 = TYPE_MIN_VALUE (dom);
+       aref.op1 = NULL_TREE;
+       aref.op2 = NULL_TREE;
+       VEC_safe_push (vn_reference_op_s, heap, mem, &aref);
+     }
    copy_reference_ops_from_ref (TREE_OPERAND (op->op0, 0), &mem);
  
    /* Do the replacement - we should have at least one op in mem now.  */
Index: gcc/testsuite/gcc.c-torture/compile/pr39648.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr39648.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr39648.c	(revision 0)
***************
*** 0 ****
--- 1,12 ----
+ void
+ yysyntax_error (char *yyp)
+ {
+         char const *yyf;
+         char yyformat[5];
+ 
+         yyf = yyformat;
+         while ((*yyp = *yyf) != '\0') {
+                 if (yyf[1] == 's')
+                         yyf += 2;
+         }
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]