OSDN Git Service

2005-01-08 Jeff Law <law@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / gimple-low.c
index 828a36f..d86cc00 100644 (file)
@@ -69,8 +69,7 @@ lower_function_body (void)
   tree_stmt_iterator i;
   tree t, x;
 
-  if (TREE_CODE (bind) != BIND_EXPR)
-    abort ();
+  gcc_assert (TREE_CODE (bind) == BIND_EXPR);
 
   data.block = DECL_INITIAL (current_function_decl);
   BLOCK_SUBBLOCKS (data.block) = NULL_TREE;
@@ -117,8 +116,7 @@ lower_function_body (void)
       tsi_link_after (&i, x, TSI_CONTINUE_LINKING);
     }
 
-  if (data.block != DECL_INITIAL (current_function_decl))
-    abort ();
+  gcc_assert (data.block == DECL_INITIAL (current_function_decl));
   BLOCK_SUBBLOCKS (data.block)
     = blocks_nreverse (BLOCK_SUBBLOCKS (data.block));
 
@@ -138,7 +136,8 @@ struct tree_opt_pass pass_lower_cf =
   PROP_gimple_lcf,                     /* properties_provided */
   PROP_gimple_any,                     /* properties_destroyed */
   0,                                   /* todo_flags_start */
-  TODO_dump_func                       /* todo_flags_finish */
+  TODO_dump_func,                      /* todo_flags_finish */
+  0                                    /* letter */
 };
 
 
@@ -199,9 +198,12 @@ lower_stmt (tree_stmt_iterator *tsi, struct lower_data *data)
       break;
 
     default:
+#ifdef ENABLE_CHECKING
       print_node_brief (stderr, "", stmt, 0);
+      internal_error ("unexpected node");
+#endif
     case COMPOUND_EXPR:
-      abort ();
+      gcc_unreachable ();
     }
 
   tsi_next (tsi);
@@ -223,15 +225,13 @@ lower_bind_expr (tree_stmt_iterator *tsi, struct lower_data *data)
          /* The outermost block of the original function may not be the
             outermost statement chain of the gimplified function.  So we
             may see the outermost block just inside the function.  */
-         if (new_block != DECL_INITIAL (current_function_decl))
-           abort ();
+         gcc_assert (new_block == DECL_INITIAL (current_function_decl));
          new_block = NULL;
        }
       else
        {
          /* We do not expect to handle duplicate blocks.  */
-         if (TREE_ASM_WRITTEN (new_block))
-           abort ();
+         gcc_assert (!TREE_ASM_WRITTEN (new_block));
          TREE_ASM_WRITTEN (new_block) = 1;
 
          /* Block tree may get clobbered by inlining.  Normally this would
@@ -251,8 +251,7 @@ lower_bind_expr (tree_stmt_iterator *tsi, struct lower_data *data)
 
   if (new_block)
     {
-      if (data->block != new_block)
-       abort ();
+      gcc_assert (data->block == new_block);
 
       BLOCK_SUBBLOCKS (new_block)
        = blocks_nreverse (BLOCK_SUBBLOCKS (new_block));
@@ -538,5 +537,60 @@ struct tree_opt_pass pass_remove_useless_vars =
   0,                                   /* properties_provided */
   0,                                   /* properties_destroyed */
   0,                                   /* todo_flags_start */
-  TODO_dump_func                       /* todo_flags_finish */
+  TODO_dump_func,                      /* todo_flags_finish */
+  0                                    /* letter */
+};
+
+/* Mark BLOCK used if it has a used variable in it, then recurse over its
+   subblocks.  */
+
+static void
+mark_blocks_with_used_vars (tree block)
+{
+  tree var;
+  tree subblock;
+
+  if (!TREE_USED (block))
+    {
+      for (var = BLOCK_VARS (block);
+          var;
+          var = TREE_CHAIN (var))
+       {
+         if (TREE_USED (var))
+           {
+             TREE_USED (block) = true;
+             break;
+           }
+       }
+    }
+  for (subblock = BLOCK_SUBBLOCKS (block);
+       subblock;
+       subblock = BLOCK_CHAIN (subblock))
+    mark_blocks_with_used_vars (subblock);
+}
+
+/* Mark the used attribute on blocks correctly.  */
+  
+static void
+mark_used_blocks (void)
+{  
+  mark_blocks_with_used_vars (DECL_INITIAL (current_function_decl));
+}
+
+
+struct tree_opt_pass pass_mark_used_blocks = 
+{
+  "blocks",                            /* name */
+  NULL,                                        /* gate */
+  mark_used_blocks,                    /* execute */
+  NULL,                                        /* sub */
+  NULL,                                        /* next */
+  0,                                   /* static_pass_number */
+  0,                                   /* tv_id */
+  0,                                   /* properties_required */
+  0,                                   /* properties_provided */
+  0,                                   /* properties_destroyed */
+  0,                                   /* todo_flags_start */
+  TODO_dump_func,                      /* todo_flags_finish */
+  0                                    /* letter */
 };