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] basic_block.h: Move goto_locus from edge to basic_block.


Hi,

Attached is a patch to move goto_locus from edge to basic_block.

goto_locus is a property of an implicit unconditional GOTO_EXPR, so it
better belongs to a basic block, not an edge.

This should reduce memory consumption somewhat as there are fewer
basic blocks than edges.

The idea for this patch was suggested by Steven Bosscher.

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

2004-11-08  Kazu Hirata  <kazu@cs.umass.edu>

	* basic-block.h (edge_def): Move goto_locus to ...
	(basic_block_def): ... here.
	* profile.c (branch_prob): Update references to goto_locus.
	* tree-cfg.c (make_goto_expr_edges, disband_implicit_edges):
	Likewise.
	* tree-pretty-print.c (dump_implicit_edges): Likewise.

Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.223
diff -u -d -p -r1.223 basic-block.h
--- basic-block.h	29 Oct 2004 08:40:51 -0000	1.223
+++ basic-block.h	6 Nov 2004 20:52:34 -0000
@@ -141,9 +141,6 @@ struct edge_def GTY(())
   /* Auxiliary info specific to a pass.  */
   PTR GTY ((skip (""))) aux;
 
-  /* Location of any goto implicit in the edge, during tree-ssa.  */
-  source_locus goto_locus;
-
   int flags;			/* see EDGE_* below  */
   int probability;		/* biased by REG_BR_PROB_BASE */
   gcov_type count;		/* Expected number of executions calculated
@@ -265,6 +262,10 @@ struct basic_block_def GTY((chain_next (
   /* Annotations used at the tree level.  */
   struct bb_ann_d *tree_annotations;
 
+  /* Location of any goto implicit in the sole outgoing edge, during
+     tree-ssa.  */
+  source_locus goto_locus;
+
   /* Expected number of executions: calculated in profile.c.  */
   gcov_type count;
 
Index: profile.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/profile.c,v
retrieving revision 1.150
diff -u -d -p -r1.150 profile.c
--- profile.c	28 Oct 2004 16:19:25 -0000	1.150
+++ profile.c	6 Nov 2004 20:52:36 -0000
@@ -1049,10 +1049,10 @@ branch_prob (void)
 
 	      /* Notice GOTO expressions we eliminated while constructing the
 		 CFG.  */
-	      if (EDGE_COUNT (bb->succs) == 1 && EDGE_SUCC (bb, 0)->goto_locus)
+	      if (EDGE_COUNT (bb->succs) == 1 && bb->goto_locus)
 		{
 		  /* ??? source_locus type is marked deprecated in input.h.  */
-		  source_locus curr_location = EDGE_SUCC (bb, 0)->goto_locus;
+		  source_locus curr_location = bb->goto_locus;
 		  /* ??? The FILE/LINE API is inconsistent for these cases.  */
 #ifdef USE_MAPPED_LOCATION 
 		  output_location (LOCATION_FILE (curr_location),
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.101
diff -u -d -p -r2.101 tree-cfg.c
--- tree-cfg.c	6 Nov 2004 15:57:25 -0000	2.101
+++ tree-cfg.c	6 Nov 2004 20:52:38 -0000
@@ -650,11 +650,11 @@ make_goto_expr_edges (basic_block bb)
       /* A GOTO to a local label creates normal edges.  */
       if (simple_goto_p (goto_t))
 	{
-	  edge e = make_edge (bb, label_to_block (dest), EDGE_FALLTHRU);
+	  make_edge (bb, label_to_block (dest), EDGE_FALLTHRU);
 #ifdef USE_MAPPED_LOCATION
-	  e->goto_locus = EXPR_LOCATION (goto_t);
+	  bb->goto_locus = EXPR_LOCATION (goto_t);
 #else
-	  e->goto_locus = EXPR_LOCUS (goto_t);
+	  bb->goto_locus = EXPR_LOCUS (goto_t);
 #endif
 	  bsi_remove (&last);
 	  return;
@@ -2510,9 +2510,9 @@ disband_implicit_edges (void)
 
       stmt = build1 (GOTO_EXPR, void_type_node, label);
 #ifdef USE_MAPPED_LOCATION
-      SET_EXPR_LOCATION (stmt, e->goto_locus);
+      SET_EXPR_LOCATION (stmt, bb->goto_locus);
 #else
-      SET_EXPR_LOCUS (stmt, e->goto_locus);
+      SET_EXPR_LOCUS (stmt, bb->goto_locus);
 #endif
       bsi_insert_after (&last, stmt, BSI_NEW_STMT);
       e->flags &= ~EDGE_FALLTHRU;
Index: tree-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-pretty-print.c,v
retrieving revision 2.47
diff -u -d -p -r2.47 tree-pretty-print.c
--- tree-pretty-print.c	27 Oct 2004 17:45:20 -0000	2.47
+++ tree-pretty-print.c	6 Nov 2004 20:52:38 -0000
@@ -2334,17 +2334,17 @@ dump_implicit_edges (pretty_printer *buf
 
       if ((flags & TDF_LINENO)
 #ifdef USE_MAPPED_LOCATION
-	  && e->goto_locus != UNKNOWN_LOCATION
+	  && bb->goto_locus != UNKNOWN_LOCATION
 #else
-	  && e->goto_locus
+	  && bb->goto_locus
 #endif
 	  )
 	{
 	  expanded_location goto_xloc;
 #ifdef USE_MAPPED_LOCATION
-	  goto_xloc = expand_location (e->goto_locus);
+	  goto_xloc = expand_location (bb->goto_locus);
 #else
-	  goto_xloc = *e->goto_locus;
+	  goto_xloc = *bb->goto_locus;
 #endif
 	  pp_character (buffer, '[');
 	  if (goto_xloc.file)


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