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]

Re: gimple vs volatiles vs enumerations


On Mon, Sep 26, 2005 at 07:17:46PM -0400, David Edelsohn wrote:
> The gimplify.c part of the original patch causes a new testsuite
> regression gcc.c-torture/execute/20000519-1.c 

I believe the following will fix the problem in a way satisfactory
for gcc 4.1.  I've just now started a ppc64-linux test run.

Longer term, tree-stdarg.c should be rewritten to use Diego's
SSA propagation engine.  At least for targets that use void*
style va_list.


r~


	* tree-stdarg.c (execute_optimize_stdarg): Treat PHIs as
	assignments for escape analysis.

Index: tree-stdarg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-stdarg.c,v
retrieving revision 2.8
diff -u -p -r2.8 tree-stdarg.c
--- tree-stdarg.c	20 Sep 2005 15:29:30 -0000	2.8
+++ tree-stdarg.c	29 Sep 2005 20:23:04 -0000
@@ -624,6 +624,7 @@ execute_optimize_stdarg (void)
   va_list_simple_ptr = POINTER_TYPE_P (va_list_type_node)
 		       && (TREE_TYPE (va_list_type_node) == void_type_node
 			   || TREE_TYPE (va_list_type_node) == char_type_node);
+  gcc_assert (is_gimple_reg_type (va_list_type_node) == va_list_simple_ptr);
 
   FOR_EACH_BB (bb)
     {
@@ -742,6 +743,50 @@ execute_optimize_stdarg (void)
 
       si.compute_sizes = -1;
       si.bb = bb;
+
+      /* For va_list_simple_ptr, we have to check PHI nodes too.  We treat
+	 them as assignments for the purpose of escape analysis.  This is
+	 not needed for non-simple va_list because virtual phis don't perform
+	 any real data movement.  */
+      if (va_list_simple_ptr)
+	{
+	  tree phi, lhs, rhs;
+	  use_operand_p uop;
+	  ssa_op_iter soi;
+
+	  for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
+	    {
+	      lhs = PHI_RESULT (phi);
+
+	      if (!is_gimple_reg (lhs))
+		continue;
+
+	      FOR_EACH_PHI_ARG (uop, phi, soi, SSA_OP_USE)
+		{
+		  rhs = USE_FROM_PTR (uop);
+		  if (va_list_ptr_read (&si, rhs, lhs))
+		    continue;
+		  else if (va_list_ptr_write (&si, lhs, rhs))
+		    continue;
+		  else
+		    check_va_list_escapes (&si, lhs, rhs);
+
+		  if (si.va_list_escapes
+		      || walk_tree (&phi, find_va_list_reference,
+				    si.va_list_vars, NULL))
+		    {
+		      if (dump_file && (dump_flags & TDF_DETAILS))
+			{
+			  fputs ("va_list escapes in ", dump_file);
+			  print_generic_expr (dump_file, phi, dump_flags);
+			  fputc ('\n', dump_file);
+			}
+		      va_list_escapes = true;
+		    }
+		}
+	    }
+	}
+
       for (i = bsi_start (bb);
 	   !bsi_end_p (i) && !va_list_escapes;
 	   bsi_next (&i))


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