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]

[tree-ssa] naming of labels in dumps


The main thing here is reusing a tree-cfg.c implementation detail
to create deterministic names for labels.  This gets rid of most 
of the garbage seen when diffing debugging dumps from two different
compilers.

In the process, I was reminded that bsi_remove should unset bb info.

Bootstrapped on i686-linux.


r~


        * tree.h (LABEL_DECL_UID): Rename from LABEL_DECL_INDEX.
        * tree-flow.h (bsi_remove): Declare.
        * tree-flow-inline.h (bsi_remove): Move ...
        * tree-cfg.c (set_bb_for_stmt): Don't re-set LABEL_DECL_UID.
        Verify that a label isn't already in a block before adding it.
        (bsi_remove): Move from tree-flow-inline.h, clear bb.
        * tree-pretty-print.c (dump_generic_node): Use LABEL_DECL_UID if set.

Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.215
diff -u -p -r1.1.4.215 tree-cfg.c
--- tree-cfg.c	14 Nov 2003 08:16:55 -0000	1.1.4.215
+++ tree-cfg.c	16 Nov 2003 08:19:45 -0000
@@ -647,7 +647,7 @@ make_switch_expr_edges (basic_block bb)
 basic_block
 label_to_block (tree dest)
 {
-  return VARRAY_BB (label_to_block_map, LABEL_DECL_INDEX (dest));
+  return VARRAY_BB (label_to_block_map, LABEL_DECL_UID (dest));
 }
 
 /* Create edges for a goto statement at block BB.  */
@@ -2281,7 +2281,6 @@ stmt_starts_bb_p (tree t, tree prev_t)
   return false;
 }
 
-
 /* Return true if T should end a basic block.  */
 
 static inline bool
@@ -2290,7 +2289,6 @@ stmt_ends_bb_p (tree t)
   return is_ctrl_stmt (t) || is_ctrl_altering_stmt (t);
 }
 
-
 /* Remove all the blocks and edges that make up the flowgraph.  */
 
 void
@@ -2344,19 +2342,33 @@ set_bb_for_stmt (tree t, basic_block bb)
     }
   else
     {
-      stmt_ann_t ann;
+      stmt_ann_t ann = get_stmt_ann (t);
+      ann->bb = bb;
 
       /* If the statement is a label, add the label to block-to-labels map
 	 so that we can speed up edge creation for GOTO_EXPRs.  */
       if (TREE_CODE (t) == LABEL_EXPR)
 	{
-	  LABEL_DECL_INDEX (LABEL_EXPR_LABEL (t))
-	      = VARRAY_ACTIVE_SIZE (label_to_block_map);
-	  VARRAY_PUSH_BB (label_to_block_map, bb);
-	}
+	  long uid;
 
-      ann = get_stmt_ann (t);
-      ann->bb = bb;
+	  t = LABEL_EXPR_LABEL (t);
+	  uid = LABEL_DECL_UID (t);
+	  if (uid == -1)
+	    {
+	      LABEL_DECL_UID (t) = VARRAY_ACTIVE_SIZE (label_to_block_map);
+	      VARRAY_PUSH_BB (label_to_block_map, bb);
+	    }
+	  else
+	    {
+#ifdef ENABLE_CHECKING
+	      /* We're moving an existing label.  Make sure that we've
+		 removed it from the old block.  */
+	      if (bb && VARRAY_BB (label_to_block_map, uid))
+		abort ();
+#endif
+	      VARRAY_BB (label_to_block_map, uid) = bb;
+	    }
+	}
     }
 }
 
@@ -2370,12 +2382,26 @@ bsi_insert_before (block_stmt_iterator *
   tsi_link_before (&i->tsi, t, m);
 }
 
+/* Insert a statement, or statement list, after the given pointer.  */
+
 void
 bsi_insert_after (block_stmt_iterator *i, tree t, enum bsi_iterator_update m)
 {
   set_bb_for_stmt (t, i->bb);
   modify_stmt (t);
   tsi_link_after (&i->tsi, t, m);
+}
+
+/* Remove the statement at the given pointer.  The pointer is updated
+   to the next statement.  */
+
+void
+bsi_remove (block_stmt_iterator *i)
+{
+  tree t = bsi_stmt (*i);
+  set_bb_for_stmt (t, NULL);
+  modify_stmt (t);
+  tsi_delink (&i->tsi);
 }
 
 /* Move the statement at FROM so it comes right after the statement at TO.  */
Index: tree-flow-inline.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow-inline.h,v
retrieving revision 1.1.2.57
diff -u -p -r1.1.2.57 tree-flow-inline.h
--- tree-flow-inline.h	12 Nov 2003 22:06:26 -0000	1.1.2.57
+++ tree-flow-inline.h	16 Nov 2003 08:19:45 -0000
@@ -529,10 +529,4 @@ bsi_stmt_ptr (block_stmt_iterator i)
   return tsi_stmt_ptr (i.tsi);
 }
 
-static inline void
-bsi_remove (block_stmt_iterator *i)
-{
-  tsi_delink (&i->tsi);
-}
-
 #endif /* _TREE_FLOW_INLINE_H  */
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.149
diff -u -p -r1.1.4.149 tree-flow.h
--- tree-flow.h	14 Nov 2003 08:16:56 -0000	1.1.4.149
+++ tree-flow.h	16 Nov 2003 08:19:46 -0000
@@ -388,6 +388,7 @@ static inline void bsi_prev (block_stmt_
 static inline tree bsi_stmt (block_stmt_iterator);
 static inline tree * bsi_stmt_ptr (block_stmt_iterator);
 
+extern void bsi_remove (block_stmt_iterator *);
 extern void bsi_move_before (block_stmt_iterator *, block_stmt_iterator *);
 extern void bsi_move_after (block_stmt_iterator *, block_stmt_iterator *);
 extern void bsi_move_to_bb_end (block_stmt_iterator *, basic_block);
Index: tree-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-pretty-print.c,v
retrieving revision 1.1.2.58
diff -u -p -r1.1.2.58 tree-pretty-print.c
--- tree-pretty-print.c	12 Nov 2003 22:06:26 -0000	1.1.2.58
+++ tree-pretty-print.c	16 Nov 2003 08:19:47 -0000
@@ -518,6 +518,9 @@ dump_generic_node (pretty_printer *buffe
     case LABEL_DECL:
       if (DECL_NAME (node))
 	pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (node)));
+      else if (LABEL_DECL_UID (node) != -1)
+        pp_printf (buffer, "<L" HOST_WIDE_INT_PRINT_DEC ">",
+		   LABEL_DECL_UID (node));
       else
         pp_printf (buffer, "<U%x>", MASK_POINTER (node));
       break;
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.342.2.125
diff -u -p -r1.342.2.125 tree.h
--- tree.h	14 Nov 2003 08:16:57 -0000	1.342.2.125
+++ tree.h	16 Nov 2003 08:19:50 -0000
@@ -2017,10 +2017,11 @@ struct tree_type GTY(())
 #define DECL_PTA_TYPEVAR(NODE) \
   (DECL_CHECK (NODE)->decl.typevar)
 
-/* Used to map between a label and the block it begins during CFG
-   construction.  Not valid any other time.  */
-#define LABEL_DECL_INDEX(NODE) \
-  (DECL_CHECK (NODE)->decl.pointer_alias_set)
+/* A numeric unique identifier for a LABEL_DECL.  The UID allocation is
+   dense, unique within any one function, and may be used to index arrays.
+   If the value is -1, then no UID has been assigned.  */
+#define LABEL_DECL_UID(NODE) \
+  (LABEL_DECL_CHECK (NODE)->decl.pointer_alias_set)
 
 /* Nonzero if an alias set has been assigned to this declaration.  */
 #define DECL_POINTER_ALIAS_SET_KNOWN_P(NODE) \


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