From 856e49c207daeb5ef0d24e43e432f6215b24ef33 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Sun, 28 Nov 2004 14:02:31 -0700 Subject: [PATCH] tree-ssa-alias.c (count_calls_and_maybe_create_global_var): New. * 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. From-SVN: r91425 --- gcc/ChangeLog | 8 +++++++ gcc/tree-optimize.c | 1 + gcc/tree-pass.h | 1 + gcc/tree-ssa-alias.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 74ea331d08b5..b040c2a8b22f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2004-11-28 Jeff Law + + * 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 * tree-inline.c (inline_forbidden_p_1, case RECORD_TYPE): Add comment. diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c index 87c73ad763b1..d60bf3ff497b 100644 --- a/gcc/tree-optimize.c +++ b/gcc/tree-optimize.c @@ -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); diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index 8900bcc6d423..f9270476859f 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -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 */ diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 4640f1fe0c43..d6391db3d7ca 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -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. */