* basic-block.h (basic_block): Add new field 'flags'.
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Aug 2001 03:22:26 +0000 (03:22 +0000)
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 Aug 2001 03:22:26 +0000 (03:22 +0000)
(BB_REACHABLE): Define.
(expunge_block): Declare.
* flow.c (ENTRY_BLOCK_PTR): Initialize field 'flags'.
(EXIT_BLOCK_PTR): Ditto.
(expunge_block): Remove static declaration.
(cleanup_cfg): Clear bb->aux on every basic block.
(find_unreachable_blocks): Set BB_REACHABLE bit in bb->flags when
computing reachability.
(delete_unreachable_blocks): Delete block b if b->flags has
BB_REACHABLE unset.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45068 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/basic-block.h
gcc/flow.c

index 1779829..5886158 100644 (file)
@@ -1,5 +1,19 @@
 2001-08-20  Diego Novillo  <dnovillo@redhat.com>
 
+       * basic-block.h (basic_block): Add new field 'flags'.
+       (BB_REACHABLE): Define.
+       (expunge_block): Declare.
+       * flow.c (ENTRY_BLOCK_PTR): Initialize field 'flags'.
+       (EXIT_BLOCK_PTR): Ditto.
+       (expunge_block): Remove static declaration.
+       (cleanup_cfg): Clear bb->aux on every basic block.
+       (find_unreachable_blocks): Set BB_REACHABLE bit in bb->flags when
+       computing reachability.
+       (delete_unreachable_blocks): Delete block b if b->flags has
+       BB_REACHABLE unset.
+
+2001-08-20  Diego Novillo  <dnovillo@redhat.com>
+
        * doc/invoke.texi: Replace references to -fdump-tree with -fdump-ast.
 
 2001-08-20  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
index dc2d190..83c4eb4 100644 (file)
@@ -218,10 +218,16 @@ typedef struct basic_block_def {
 
   /* Expected frequency.  Normalized to be in range 0 to BB_FREQ_MAX.  */
   int frequency;
+
+  /* Various flags.  See BB_* below.  */
+  int flags;
 } *basic_block;
 
 #define BB_FREQ_MAX 10000
 
+/* Masks for basic_block.flags.  */
+#define BB_REACHABLE           1
+
 /* Number of basic blocks in the current function.  */
 
 extern int n_basic_blocks;
@@ -609,6 +615,7 @@ extern void debug_regset            PARAMS ((regset));
 extern void allocate_reg_life_data      PARAMS ((void));
 extern void allocate_bb_life_data      PARAMS ((void));
 extern void find_unreachable_blocks    PARAMS ((void));
+extern void expunge_block              PARAMS ((basic_block));
 extern void delete_noop_moves          PARAMS ((rtx));
 extern rtx last_loop_beg_note          PARAMS ((rtx));
 extern basic_block redirect_edge_and_branch_force PARAMS ((edge, basic_block));
index 6a316e2..8e0b813 100644 (file)
@@ -208,7 +208,8 @@ struct basic_block_def entry_exit_blocks[2]
     ENTRY_BLOCK,               /* index */
     0,                         /* loop_depth */
     0,                         /* count */
-    0                          /* frequency */
+    0,                         /* frequency */
+    0                          /* flags */
   },
   {
     NULL,                      /* head */
@@ -225,7 +226,8 @@ struct basic_block_def entry_exit_blocks[2]
     EXIT_BLOCK,                        /* index */
     0,                         /* loop_depth */
     0,                         /* count */
-    0                          /* frequency */
+    0,                         /* frequency */
+    0                          /* flags */
   }
 };
 
@@ -383,7 +385,6 @@ static void commit_one_edge_insertion       PARAMS ((edge));
 
 static void delete_unreachable_blocks  PARAMS ((void));
 static int can_delete_note_p           PARAMS ((rtx));
-static void expunge_block              PARAMS ((basic_block));
 static int can_delete_label_p          PARAMS ((rtx));
 static int tail_recursion_label_p      PARAMS ((rtx));
 static int merge_blocks_move_predecessor_nojumps PARAMS ((basic_block,
@@ -1030,6 +1031,8 @@ void
 cleanup_cfg (mode)
      int mode;
 {
+  int i;
+
   timevar_push (TV_CLEANUP_CFG);
   delete_unreachable_blocks ();
   if (try_optimize_cfg (mode))
@@ -1040,6 +1043,10 @@ cleanup_cfg (mode)
   free_EXPR_LIST_list (&label_value_list);
   free_EXPR_LIST_list (&tail_recursion_label_list);
   timevar_pop (TV_CLEANUP_CFG);
+
+  /* Clear bb->aux on all basic blocks.  */
+  for (i = 0; i < n_basic_blocks; ++i)
+    BASIC_BLOCK (i)->aux = NULL;
 }
 
 /* Create a new basic block consisting of the instructions between
@@ -2643,8 +2650,9 @@ flow_call_edges_add (blocks)
   return blocks_split;
 }
 \f
-/* Find unreachable blocks.  An unreachable block will have NULL in
-   block->aux, a non-NULL value indicates the block is reachable.  */
+/* Find unreachable blocks.  An unreachable block will have 0 in
+   the reachable bit in block->flags.  A non-zero value indicates the
+   block is reachable.  */
 
 void
 find_unreachable_blocks ()
@@ -2656,10 +2664,10 @@ find_unreachable_blocks ()
   n = n_basic_blocks;
   tos = worklist = (basic_block *) xmalloc (sizeof (basic_block) * n);
 
-  /* Use basic_block->aux as a marker.  Clear them all.  */
+  /* Clear all the reachability flags.  */
 
   for (i = 0; i < n; ++i)
-    BASIC_BLOCK (i)->aux = NULL;
+    BASIC_BLOCK (i)->flags &= ~BB_REACHABLE;
 
   /* Add our starting points to the worklist.  Almost always there will
      be only one.  It isn't inconcievable that we might one day directly
@@ -2669,8 +2677,8 @@ find_unreachable_blocks ()
     {
       *tos++ = e->dest;
 
-      /* Mark the block with a handy non-null value.  */
-      e->dest->aux = e;
+      /* Mark the block reachable.  */
+      e->dest->flags |= BB_REACHABLE;
     }
 
   /* Iterate: find everything reachable from what we've already seen.  */
@@ -2680,10 +2688,10 @@ find_unreachable_blocks ()
       basic_block b = *--tos;
 
       for (e = b->succ; e; e = e->succ_next)
-       if (!e->dest->aux)
+       if (!(e->dest->flags & BB_REACHABLE))
          {
            *tos++ = e->dest;
-           e->dest->aux = e;
+           e->dest->flags |= BB_REACHABLE;
          }
     }
 
@@ -2706,10 +2714,7 @@ delete_unreachable_blocks ()
     {
       basic_block b = BASIC_BLOCK (i);
 
-      if (b->aux != NULL)
-       /* This block was found.  Tidy up the mark.  */
-       b->aux = NULL;
-      else
+      if (!(b->flags & BB_REACHABLE))
        flow_delete_block (b);
     }
 
@@ -2845,7 +2850,7 @@ flow_delete_block (b)
 
 /* Remove block B from the basic block array and compact behind it.  */
 
-static void
+void
 expunge_block (b)
      basic_block b;
 {