OSDN Git Service

* tree-ssa-alias.c (count_calls_and_maybe_create_global_var): New.
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 28 Nov 2004 21:02:31 +0000 (21:02 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 28 Nov 2004 21:02:31 +0000 (21:02 +0000)
        (pass_maybe_create_global_var): New.
        * tree-pass.h (pass_maybe_create_global_var): Declare.
        * tree-optimize.c (init_tree_optimization_passes): Link in
        pass_maybe_create_global_var.

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

gcc/ChangeLog
gcc/tree-optimize.c
gcc/tree-pass.h
gcc/tree-ssa-alias.c

index 74ea331..b040c2a 100644 (file)
@@ -1,3 +1,11 @@
+2004-11-28  Jeff Law  <law@redhat.com>
+
+       * tree-ssa-alias.c (count_calls_and_maybe_create_global_var): New.
+       (pass_maybe_create_global_var): New.
+       * tree-pass.h (pass_maybe_create_global_var): Declare.
+       * tree-optimize.c (init_tree_optimization_passes): Link in
+       pass_maybe_create_global_var.
+
 2004-11-28  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
        * tree-inline.c (inline_forbidden_p_1, case RECORD_TYPE): Add comment.
index 87c73ad..d60bf3f 100644 (file)
@@ -345,6 +345,7 @@ init_tree_optimization_passes (void)
 
   p = &pass_all_optimizations.sub;
   NEXT_PASS (pass_referenced_vars);
+  NEXT_PASS (pass_maybe_create_global_var);
   NEXT_PASS (pass_build_ssa);
   NEXT_PASS (pass_may_alias);
   NEXT_PASS (pass_rename_ssa_copies);
index 8900bcc..f927047 100644 (file)
@@ -163,5 +163,6 @@ extern struct tree_opt_pass pass_expand;
 extern struct tree_opt_pass pass_rest_of_compilation;
 extern struct tree_opt_pass pass_fre;
 extern struct tree_opt_pass pass_linear_transform;
+extern struct tree_opt_pass pass_maybe_create_global_var;
 
 #endif /* GCC_TREE_PASS_H */
index 4640f1f..d6391db 100644 (file)
@@ -357,6 +357,62 @@ struct tree_opt_pass pass_may_alias =
   0                                    /* letter */
 };
 
+/* Count the number of calls in the function and conditionally
+   create GLOBAL_VAR.   This is performed before translation
+   into SSA (and thus before alias analysis) to avoid compile time
+   and memory utilization explosions in functions with many
+   of calls and call clobbered variables.  */
+
+static void
+count_calls_and_maybe_create_global_var (void)
+{
+  struct alias_info ai;
+  basic_block bb;
+  bool temp;
+
+  memset (&ai, 0, sizeof (struct alias_info));
+
+  /* First count the number of calls in the IL.  */
+  FOR_EACH_BB (bb)
+    {
+      block_stmt_iterator si;
+
+      for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
+        {
+          tree stmt = bsi_stmt (si);
+
+         if (get_call_expr_in (stmt) != NULL_TREE)
+           ai.num_calls_found++;
+       }
+    }
+
+  /* If there are no call clobbered variables, then maybe_create_global_var
+     will always create a GLOBAL_VAR.  At this point we do not want that
+     behavior.  So we turn on one bit in CALL_CLOBBERED_VARs, call
+     maybe_create_global_var, then reset the bit to its original state.  */
+  temp = bitmap_bit_p (call_clobbered_vars, 0);
+  bitmap_set_bit (call_clobbered_vars, 0);
+  maybe_create_global_var (&ai);
+  if (!temp)
+    bitmap_clear_bit (call_clobbered_vars, 0);
+}
+
+struct tree_opt_pass pass_maybe_create_global_var = 
+{
+  "maybe_create_global_var",           /* name */
+  NULL,                                        /* gate */
+  count_calls_and_maybe_create_global_var, /* execute */
+  NULL,                                        /* sub */
+  NULL,                                        /* next */
+  0,                                   /* static_pass_number */
+  TV_TREE_MAY_ALIAS,                   /* tv_id */
+  PROP_cfg,                            /* properties_required */
+  0,                                   /* properties_provided */
+  0,                                   /* properties_destroyed */
+  0,                                   /* todo_flags_start */
+  0,                                   /* todo_flags_finish */
+  0                                    /* letter */
+};
 
 /* Initialize the data structures used for alias analysis.  */