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]

[dataflow]: PATCH COMMITTED to fix dumps and a register allocation problem.


This patch fixes two problems:

First, the register usage information is modified by local_alloc before
global alloc sees it.  This patch keeps global from recomputing that
information from scratch when it redoes the data flow analysis since the
changes that are made by local are somewhat non standard.

The other issue fixed by this patch is to print the hard register names
in the dump file for all of the register sets. 

2006-11-04  Kenneth Zadeck <zadeck@naturalbridge.com>
    * df-scan.c (df_scan_start_dump): Changed print routine to print
    hard register names.
    * df-core.c (df_print_regset): New function.
    * global.c (global_alloc): Do not recompute register infomation
    when recomputing dataflow.
    * df.h (DF_RI_NO_UPDATE): New flag. 
    * df-problems.c (df_lr_top_dump, df_lr_bottom_dump,
    df_ur_top_dump, df_ur_bottom_dump, df_live_top_dump,
    df_live_bottom_dump, df_urec_top_dump, df_urec_bottom_dump):
    Changed to use df_print_regset.
    (df_ri_alloc, df_ri_compute): Changed to not update if
    DF_RI_NO_UPDATE flag.
    * cfgrtl.c (print_rtl_with_bb): Changed to print preds and
    successor blocks in dump file.
   


Bootstrapped and tested on x86-64-linux.

Kenny
Index: ChangeLog.dataflow
===================================================================
--- ChangeLog.dataflow	(revision 118481)
+++ ChangeLog.dataflow	(working copy)
@@ -1,3 +1,19 @@
+2006-10-19  Kenneth Zadeck <zadeck@naturalbridge.com>
+	* df-scan.c (df_scan_start_dump): Changed print routine to print
+	hard register names.
+	* df-core.c (df_print_regset): New function.
+	* global.c (global_alloc): Do not recompute register infomation
+	when recomputing dataflow.
+	* df.h (DF_RI_NO_UPDATE): New flag.  
+	* df-problems.c (df_lr_top_dump, df_lr_bottom_dump,
+	df_ur_top_dump, df_ur_bottom_dump, df_live_top_dump,
+	df_live_bottom_dump, df_urec_top_dump, df_urec_bottom_dump): 
+	Changed to use df_print_regset.
+	(df_ri_alloc, df_ri_compute): Changed to not update if
+	DF_RI_NO_UPDATE flag.
+	* cfgrtl.c (print_rtl_with_bb): Changed to print preds and
+	successor blocks in dump file.
+	
 2006-11-03  Seongbae Park <seongbae.park@gmail.com>
 	* global.c (global_conflicts): Use df_urec_get_live_at_top ()
 	instead of DF_RA_LIVE_IN ().
Index: df-scan.c
===================================================================
--- df-scan.c	(revision 118481)
+++ df-scan.c	(working copy)
@@ -343,21 +343,26 @@ df_scan_start_dump (struct dataflow *dfl
   int i;
 
   fprintf (file, "  invalidated by call \t");
-  dump_bitmap (file, df_invalidated_by_call);
+  df_print_regset (file, df_invalidated_by_call);
   fprintf (file, "  hardware regs used \t");
-  dump_bitmap (file, df->hardware_regs_used);
+  df_print_regset (file, df->hardware_regs_used);
   fprintf (file, "  regular block artificial uses \t");
-  dump_bitmap (file, df->regular_block_artificial_uses);
+  df_print_regset (file, df->regular_block_artificial_uses);
   fprintf (file, "  eh block artificial uses \t");
-  dump_bitmap (file, df->eh_block_artificial_uses);
+  df_print_regset (file, df->eh_block_artificial_uses);
   fprintf (file, "  entry block defs \t");
-  dump_bitmap (file, df->entry_block_defs);
+  df_print_regset (file, df->entry_block_defs);
   fprintf (file, "  exit block uses \t");
-  dump_bitmap (file, df->exit_block_uses);
+  df_print_regset (file, df->exit_block_uses);
   fprintf (file, "  regs ever live \t");
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
     if (regs_ever_live[i])
-      fprintf (file, "%d ", i);
+      {
+	fprintf (file, " %d", i);
+	if (i < FIRST_PSEUDO_REGISTER)
+	  fprintf (file, " [%s]", reg_names[i]);
+      }
+
   fprintf (file, "\n");
 }
 
Index: df-core.c
===================================================================
--- df-core.c	(revision 118481)
+++ df-core.c	(working copy)
@@ -1095,6 +1095,31 @@ df_reg_used (struct df *df, rtx insn, rt
    Debugging and printing functions.
 ----------------------------------------------------------------------------*/
 
+
+/* Write information about registers and basic blocks into FILE.
+   This is part of making a debugging dump.  */
+
+void
+df_print_regset (FILE *file, bitmap r)
+{
+  unsigned int i;
+  bitmap_iterator bi;
+
+  if (r == NULL)
+    fputs (" (nil)", file);
+  else
+    {
+      EXECUTE_IF_SET_IN_BITMAP (r, 0, i, bi)
+	{
+	  fprintf (file, " %d", i);
+	  if (i < FIRST_PSEUDO_REGISTER)
+	    fprintf (file, " [%s]", reg_names[i]);
+	}
+    }
+  fprintf (file, "\n");
+}
+
+
 /* Dump dataflow info.  */
 void
 df_dump (struct df *df, FILE *file)
Index: global.c
===================================================================
--- global.c	(revision 118481)
+++ global.c	(working copy)
@@ -333,6 +333,9 @@ global_alloc (void)
   compact_blocks ();
 
   max_allocno = 0;
+  /* Do not recompute the register info.  Local_alloc has played with
+     this in a way that global expects.  */
+  df_set_flags (ra_df, DF_RI_NO_UPDATE);
   df_analyze (ra_df);
 
   /* A machine may have certain hard registers that
@@ -490,6 +493,18 @@ global_alloc (void)
     if (regs_ever_live[i])
       local_reg_n_refs[i] = 0, local_reg_freq[i] = 0;
 
+  if (dump_file)
+    {
+      for (i = FIRST_PSEUDO_REGISTER; i < (size_t) max_regno; i++)
+	{
+	  fprintf (dump_file, "%d REG_N_REFS=%d, REG_FREQ=%d, REG_LIVE_LENGTH=%d\n", 
+		   (int)i, REG_N_REFS (i), REG_FREQ (i), REG_LIVE_LENGTH (i));
+	}
+      fprintf (dump_file, "regs_ever_live =");
+      for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+	fprintf (dump_file, " %d", (int)i);
+      fprintf (dump_file, "\n");
+    }
   allocno_row_words = (max_allocno + INT_BITS - 1) / INT_BITS;
 
   /* We used to use alloca here, but the size of what it would try to
Index: df.h
===================================================================
--- df.h	(revision 118481)
+++ df.h	(working copy)
@@ -332,7 +332,8 @@ enum df_changeable_flags 
   /* Flag to control the running of dce as a side effect of building LR.  */
   DF_LR_RUN_DCE    = 1,  /* Run DCE.  */
   DF_NO_HARD_REGS  = 2,  /* Skip hard registers in RD and CHAIN Building.  */
-  DF_EQ_NOTES      = 4   /* Build chains with uses present in EQUIV/EQUAL notes. */
+  DF_EQ_NOTES      = 4,  /* Build chains with uses present in EQUIV/EQUAL notes. */
+  DF_RI_NO_UPDATE  = 8   /* Do not update the register info when df_analyze is run.  */
 };
 
 /* Two of these structures are inline in df, one for the uses and one
@@ -687,6 +688,7 @@ extern bool df_reg_defined (struct df *,
 extern struct df_ref *df_find_use (struct df *, rtx, rtx);
 extern bool df_reg_used (struct df *, rtx, rtx);
 extern void df_iterative_dataflow (struct dataflow *, bitmap, bitmap, int *, int, bool);
+extern void df_print_regset (FILE *file, bitmap r);
 extern void df_dump (struct df *, FILE *);
 extern void df_dump_start (struct df *, FILE *);
 extern void df_dump_top (struct df *, basic_block, FILE *);
Index: df-problems.c
===================================================================
--- df-problems.c	(revision 118481)
+++ df-problems.c	(working copy)
@@ -1885,11 +1885,11 @@ df_lr_top_dump (struct dataflow *dflow, 
     return;
       
   fprintf (file, "lr  in  \t");
-  dump_bitmap (file, bb_info->in);
+  df_print_regset (file, bb_info->in);
   fprintf (file, "lr  use \t");
-  dump_bitmap (file, bb_info->use);
+  df_print_regset (file, bb_info->use);
   fprintf (file, "lr  def \t");
-  dump_bitmap (file, bb_info->def);
+  df_print_regset (file, bb_info->def);
 }  
 
 
@@ -1903,7 +1903,7 @@ df_lr_bottom_dump (struct dataflow *dflo
     return;
   
   fprintf (file, "lr  out \t");
-  dump_bitmap (file, bb_info->out);
+  df_print_regset (file, bb_info->out);
 }  
 
 
@@ -2207,11 +2207,11 @@ df_ur_top_dump (struct dataflow *dflow, 
     return;
       
   fprintf (file, "ur  in  \t");
-  dump_bitmap (file, bb_info->in);
+  df_print_regset (file, bb_info->in);
   fprintf (file, "ur  gen \t");
-  dump_bitmap (file, bb_info->gen);
+  df_print_regset (file, bb_info->gen);
   fprintf (file, "ur  kill\t");
-  dump_bitmap (file, bb_info->kill);
+  df_print_regset (file, bb_info->kill);
 }
 
 
@@ -2225,7 +2225,7 @@ df_ur_bottom_dump (struct dataflow *dflo
     return;
       
   fprintf (file, "ur  out \t");
-  dump_bitmap (file, bb_info->out);
+  df_print_regset (file, bb_info->out);
 }
 
 
@@ -2405,7 +2405,7 @@ df_live_top_dump (struct dataflow *dflow
     return;
   
   fprintf (file, "live  in  \t");
-  dump_bitmap (file, bb_info->in);
+  df_print_regset (file, bb_info->in);
 }
 
 
@@ -2419,7 +2419,7 @@ df_live_bottom_dump (struct dataflow *df
     return;
   
   fprintf (file, "live  out  \t");
-  dump_bitmap (file, bb_info->out);
+  df_print_regset (file, bb_info->out);
 }
 
 
@@ -3036,13 +3036,13 @@ df_urec_top_dump (struct dataflow *dflow
     return;
       
   fprintf (file, "urec  in  \t");
-  dump_bitmap (file, bb_info->in);
+  df_print_regset (file, bb_info->in);
   fprintf (file, "urec  gen \t");
-  dump_bitmap (file, bb_info->gen);
+  df_print_regset (file, bb_info->gen);
   fprintf (file, "urec  kill\t");
-  dump_bitmap (file, bb_info->kill);
+  df_print_regset (file, bb_info->kill);
   fprintf (file, "urec  ec\t");
-  dump_bitmap (file, bb_info->earlyclobber);
+  df_print_regset (file, bb_info->earlyclobber);
 }
 
 
@@ -3055,7 +3055,7 @@ df_urec_bottom_dump (struct dataflow *df
   if (!bb_info || !bb_info->out)
     return;
   fprintf (file, "urec  out \t");
-  dump_bitmap (file, bb_info->out);
+  df_print_regset (file, bb_info->out);
 }
 
 
@@ -3566,6 +3566,9 @@ df_ri_alloc (struct dataflow *dflow, 
   struct df_ri_problem_data *problem_data =
     (struct df_ri_problem_data *) dflow->problem_data;
 
+  if (df->changeable_flags & DF_RI_NO_UPDATE)
+    return;
+
   if (!dflow->problem_data)
     {
       problem_data = XNEW (struct df_ri_problem_data);
@@ -4141,6 +4144,9 @@ df_ri_compute (struct dataflow *dflow, b
   struct df_ri_problem_data *problem_data =
     (struct df_ri_problem_data *) dflow->problem_data;
 
+  if (df->changeable_flags & DF_RI_NO_UPDATE)
+    return;
+
   if (df->permanent_flags & DF_RI_LIFE)
     {
       local_live = BITMAP_ALLOC (NULL);
Index: cfgrtl.c
===================================================================
--- cfgrtl.c	(revision 118481)
+++ cfgrtl.c	(working copy)
@@ -1643,7 +1643,14 @@ print_rtl_with_bb (FILE *outf, rtx rtx_f
 	  
 	  if ((bb = start[INSN_UID (tmp_rtx)]) != NULL)
 	    {
-	      fprintf (outf, ";; Start of basic block %d\n", bb->index);
+	      edge e;
+	      edge_iterator ei;
+	      
+	      fprintf (outf, ";; Start of basic block (");
+	      FOR_EACH_EDGE (e, ei, bb->preds)
+		fprintf (outf, " %d", e->src->index);
+	      fprintf (outf, ") -> %d\n", bb->index);
+
 	      if (df)
 		{
 		  df_dump_top (df, bb, outf);
@@ -1662,7 +1669,14 @@ print_rtl_with_bb (FILE *outf, rtx rtx_f
 
 	  if ((bb = end[INSN_UID (tmp_rtx)]) != NULL)
 	    {
-	      fprintf (outf, ";; End of basic block %d\n", bb->index);
+	      edge e;
+	      edge_iterator ei;
+
+	      fprintf (outf, ";; End of basic block %d -> (", bb->index);
+	      FOR_EACH_EDGE (e, ei, bb->succs)
+		fprintf (outf, " %d", e->dest->index);
+	      fprintf (outf, ")\n");
+
 	      if (df)
 		{
 		  df_dump_bottom (df, bb, outf);

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