This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [trunk] PATCH: unique names for patches.
Hello All,
Ralf Wildenhues wrote:
Hello Basile,
a couple of nits:
> [....]
Thanks for the suggestions. I followed them in the updated patch to
trunk rev.138523 attached.
I further assume you've tried to expose the failure with naming two
passes identically?
Yes I did. It wasn't hard, several passes used to be homonymous :-(
What I don't know is if some passes names are mentioned in the testsuite.
Now gcc/ChangeLog is:
2008-08-01 Basile Starynkevitch <basile@starynkevitch.net>
* Makefile.in: Change dependencies for passes.c.
(pass_is_dumpable) New function.
* cfgrtl.c (pass_free_cfg): Added name.
* cgraphbuild.c (pass_build_cgraph_edges)
(pass_rebuild_cgraph_edges): Added name.
* dce.c (pass_ud_rtl_dce, pass_fast_rtl_dce): Changed name.
* df-core.c (pass_df_initialize_opt, pass_df_initialize_no_opt):
Changed name.
* except.c (pass_set_nothrow_function_flags): Added name.
* final.c (pass_final, pass_clean_state): Added name.
* function.c (pass_init_function, pass_leaf_regs): Added name.
* ipa-inline.c (pass_inline_parameters): Added name.
* passes.c: include hashtab.h.
(hash_pass, eq_pass): New functions.
(pass_rest_of_compilation): Added name.
(register_dump_files_1): Test if pass_is_dumpable.
(next_pass_1): Check if pass is unique when ENABLE_CHECKING.
(init_optimization_passes): Create pass_hash table when
ENABLE_CHECKING.
(pass_init_dump_file): Test if pass_is_dumpable.
* reg-stack.c (pass_stack_regs): Added name.
* stack-ptr-mod.c (pass_stack_ptr_mod): Added name.
* statistics.c (statistics_fini_pass): Test if pass_is_dumpable.
* tree-cfg.c (pass_warn_function_return)
(pass_warn_function_noreturn): Changed name.
* tree-dfa.c (pass_referenced_vars): Added name.
* tree-eh.c (pass_lower_eh): Changed name.
* tree-optimize.c (pass_all_optimizations): Added name.
* tree-pass.h (struct opt_pass): Changed comment about name field.
* tree-ssa-alias.c (pass_reset_cc_flags): Added name.
* tree-ssa-dse.c (pass_dce): Changed name.
* tree-ssa-loop.c (pass_record_bounds): Added name.
* tree-ssa.c (pass_early_warn_uninitialized)
(pass_late_warn_uninitialized): Added name.
* doc/passes.texi (Pass manager): Mention that passes should have
a unique name.
On my Debian/Sid/amd64 x86_64-unknown-linux-gnu the patch bootstraps
with ..../configure '--enable-checks=all' '--disable-multilib'
'--enable-languages=c,c++'
Ok for trunk?
Thanks.
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***
Index: gcc/doc/passes.texi
===================================================================
--- gcc/doc/passes.texi (revision 138523)
+++ gcc/doc/passes.texi (working copy)
@@ -166,9 +166,9 @@ not attempt to (re-)generate data structures or lo
language form based on the requirements of the next pass. Nevertheless,
what is present is useful, and a far sight better than nothing at all.
-Each pass may have its own dump file (for GCC debugging purposes).
-Passes without any names, or with a name starting with a star, do not
-dump anything.
+Each pass may have its own dump file (for GCC debugging purposes) and
+should have a unique name. Passes with a name starting with a star
+do not dump anything.
TODO: describe the global variables set up by the pass manager,
and a brief description of how a new pass should use it.
Index: gcc/cgraphbuild.c
===================================================================
--- gcc/cgraphbuild.c (revision 138523)
+++ gcc/cgraphbuild.c (working copy)
@@ -203,7 +203,7 @@ struct gimple_opt_pass pass_build_cgraph_edges =
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*build-cgraph-edges", /* *no-dump* name */
NULL, /* gate */
build_cgraph_edges, /* execute */
NULL, /* sub */
@@ -264,7 +264,7 @@ struct gimple_opt_pass pass_rebuild_cgraph_edges =
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*rebuild_cgraph", /* *no-dump* name */
NULL, /* gate */
rebuild_cgraph_edges, /* execute */
NULL, /* sub */
Index: gcc/tree-pass.h
===================================================================
--- gcc/tree-pass.h (revision 138523)
+++ gcc/tree-pass.h (working copy)
@@ -104,8 +104,10 @@ struct opt_pass
SIMPLE_IPA_PASS,
IPA_PASS
} type;
- /* Terse name of the pass used as a fragment of the dump file
- name. If the name starts with a star, no dump happens. */
+
+ /* Terse name of the pass used as a fragment of the dump file name.
+ Every pass should be uniquely named. If the name starts with a
+ star, no dump happens. */
const char *name;
/* If non-null, this pass and all sub-passes are executed only if
@@ -140,6 +142,13 @@ struct opt_pass
unsigned int todo_flags_finish;
};
+/* dumpable passes have a name not starting with a star */
+static inline bool
+pass_is_dumpable (const struct opt_pass* pass)
+{
+ return pass->name && pass->name[0] != '*';
+}
+
/* Description of GIMPLE pass. */
struct gimple_opt_pass
{
Index: gcc/final.c
===================================================================
--- gcc/final.c (revision 138523)
+++ gcc/final.c (working copy)
@@ -4199,7 +4199,7 @@ struct rtl_opt_pass pass_final =
{
{
RTL_PASS,
- NULL, /* name */
+ "*final", /* *no-dump* name */
NULL, /* gate */
rest_of_handle_final, /* execute */
NULL, /* sub */
@@ -4311,7 +4311,7 @@ struct rtl_opt_pass pass_clean_state =
{
{
RTL_PASS,
- NULL, /* name */
+ "*clean_state", /* *no-dump* name */
NULL, /* gate */
rest_of_clean_state, /* execute */
NULL, /* sub */
Index: gcc/df-core.c
===================================================================
--- gcc/df-core.c (revision 138523)
+++ gcc/df-core.c (working copy)
@@ -760,7 +760,7 @@ struct rtl_opt_pass pass_df_initialize_opt =
{
{
RTL_PASS,
- "dfinit", /* name */
+ "dfinit_opt", /* name */
gate_opt, /* gate */
rest_of_handle_df_initialize, /* execute */
NULL, /* sub */
@@ -787,7 +787,7 @@ struct rtl_opt_pass pass_df_initialize_no_opt =
{
{
RTL_PASS,
- "dfinit", /* name */
+ "dfinit_no_opt", /* name */
gate_no_opt, /* gate */
rest_of_handle_df_initialize, /* execute */
NULL, /* sub */
Index: gcc/tree-ssa-alias.c
===================================================================
--- gcc/tree-ssa-alias.c (revision 138523)
+++ gcc/tree-ssa-alias.c (working copy)
@@ -3770,9 +3770,9 @@ struct gimple_opt_pass pass_reset_cc_flags =
{
{
GIMPLE_PASS,
- NULL, /* name */
- NULL, /* gate */
- reset_cc_flags, /* execute */
+ "*reset_cc_flags", /* *no-dump* name */
+ NULL, /* gate */
+ reset_cc_flags, /* execute */
NULL, /* sub */
NULL, /* next */
0, /* static_pass_number */
Index: gcc/ipa-inline.c
===================================================================
--- gcc/ipa-inline.c (revision 138523)
+++ gcc/ipa-inline.c (working copy)
@@ -1611,7 +1611,7 @@ struct gimple_opt_pass pass_inline_parameters =
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*inline-param", /* *no-dump* name */
NULL, /* gate */
compute_inline_parameters_for_current,/* execute */
NULL, /* sub */
Index: gcc/tree-ssa-loop.c
===================================================================
--- gcc/tree-ssa-loop.c (revision 138523)
+++ gcc/tree-ssa-loop.c (working copy)
@@ -437,7 +437,7 @@ struct gimple_opt_pass pass_record_bounds =
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*record_bounds", /* *no-dump* name */
NULL, /* gate */
tree_ssa_loop_bounds, /* execute */
NULL, /* sub */
Index: gcc/tree-eh.c
===================================================================
--- gcc/tree-eh.c (revision 138523)
+++ gcc/tree-eh.c (working copy)
@@ -1912,7 +1912,7 @@ struct gimple_opt_pass pass_lower_eh =
{
{
GIMPLE_PASS,
- "eh", /* name */
+ "lower_eh", /* name */
NULL, /* gate */
lower_eh_constructs, /* execute */
NULL, /* sub */
Index: gcc/function.c
===================================================================
--- gcc/function.c (revision 138523)
+++ gcc/function.c (working copy)
@@ -4078,7 +4078,7 @@ struct rtl_opt_pass pass_init_function =
{
{
RTL_PASS,
- NULL, /* name */
+ "*init_function", /* *no-dump* name */
NULL, /* gate */
init_function_for_compilation, /* execute */
NULL, /* sub */
@@ -5249,7 +5249,7 @@ struct rtl_opt_pass pass_leaf_regs =
{
{
RTL_PASS,
- NULL, /* name */
+ "*leaf_regs", /* *no-dump* name */
NULL, /* gate */
rest_of_handle_check_leaf_regs, /* execute */
NULL, /* sub */
Index: gcc/tree-dfa.c
===================================================================
--- gcc/tree-dfa.c (revision 138523)
+++ gcc/tree-dfa.c (working copy)
@@ -117,7 +117,7 @@ struct gimple_opt_pass pass_referenced_vars =
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*referenced_vars", /* *no-dump* name */
NULL, /* gate */
find_referenced_vars, /* execute */
NULL, /* sub */
Index: gcc/except.c
===================================================================
--- gcc/except.c (revision 138523)
+++ gcc/except.c (working copy)
@@ -2810,7 +2810,7 @@ struct rtl_opt_pass pass_set_nothrow_function_flag
{
{
RTL_PASS,
- NULL, /* name */
+ "*set_nothrow_function_flags", /* *no-dump* name */
NULL, /* gate */
set_nothrow_function_flags, /* execute */
NULL, /* sub */
Index: gcc/tree-ssa-dce.c
===================================================================
--- gcc/tree-ssa-dce.c (revision 138523)
+++ gcc/tree-ssa-dce.c (working copy)
@@ -907,7 +907,7 @@ struct gimple_opt_pass pass_dce =
{
{
GIMPLE_PASS,
- "dce", /* name */
+ "ssa_dce", /* name */
gate_dce, /* gate */
tree_ssa_dce, /* execute */
NULL, /* sub */
Index: gcc/tree-ssa.c
===================================================================
--- gcc/tree-ssa.c (revision 138523)
+++ gcc/tree-ssa.c (working copy)
@@ -1540,7 +1540,7 @@ struct gimple_opt_pass pass_early_warn_uninitializ
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*early_warn_uninitialized", /* *no-dump* name */
gate_warn_uninitialized, /* gate */
execute_early_warn_uninitialized, /* execute */
NULL, /* sub */
@@ -1559,7 +1559,7 @@ struct gimple_opt_pass pass_late_warn_uninitialize
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*late_warn_uninitialized", /* *no-dump* name */
gate_warn_uninitialized, /* gate */
execute_late_warn_uninitialized, /* execute */
NULL, /* sub */
Index: gcc/tree-optimize.c
===================================================================
--- gcc/tree-optimize.c (revision 138523)
+++ gcc/tree-optimize.c (working copy)
@@ -65,7 +65,7 @@ struct gimple_opt_pass pass_all_optimizations =
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*all_optimizations", /* *no-dump* name */
gate_all_optimizations, /* gate */
NULL, /* execute */
NULL, /* sub */
@@ -234,9 +234,9 @@ struct gimple_opt_pass pass_free_datastructures =
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*free_datastructures", /* *no-dump* name */
NULL, /* gate */
- execute_free_datastructures, /* execute */
+ execute_free_datastructures, /* execute */
NULL, /* sub */
NULL, /* next */
0, /* static_pass_number */
@@ -263,7 +263,7 @@ struct gimple_opt_pass pass_free_cfg_annotations =
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*free_cfg_annotations", /* *no-dump* name */
NULL, /* gate */
execute_free_cfg_annotations, /* execute */
NULL, /* sub */
@@ -346,7 +346,7 @@ struct gimple_opt_pass pass_init_datastructures =
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*init_datastructures", /* *no-dump* name */
NULL, /* gate */
execute_init_datastructures, /* execute */
NULL, /* sub */
Index: gcc/stack-ptr-mod.c
===================================================================
--- gcc/stack-ptr-mod.c (revision 138523)
+++ gcc/stack-ptr-mod.c (working copy)
@@ -95,7 +95,7 @@ struct rtl_opt_pass pass_stack_ptr_mod =
{
{
RTL_PASS,
- NULL, /* name */
+ "*stack_ptr_mod", /* *no-dump* name */
NULL, /* gate */
rest_of_handle_stack_ptr_mod, /* execute */
NULL, /* sub */
Index: gcc/reg-stack.c
===================================================================
--- gcc/reg-stack.c (revision 138523)
+++ gcc/reg-stack.c (working copy)
@@ -3203,7 +3203,7 @@ struct rtl_opt_pass pass_stack_regs =
{
{
RTL_PASS,
- NULL, /* name */
+ "*stack_regs", /* *no-dump* name */
gate_handle_stack_regs, /* gate */
NULL, /* execute */
NULL, /* sub */
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in (revision 138523)
+++ gcc/Makefile.in (working copy)
@@ -2423,7 +2423,7 @@ passes.o : passes.c $(CONFIG_H) $(SYSTEM_H) corety
langhooks.h insn-flags.h $(CFGLAYOUT_H) $(REAL_H) $(CFGLOOP_H) \
hosthooks.h $(CGRAPH_H) $(COVERAGE_H) tree-pass.h $(TREE_DUMP_H) \
$(GGC_H) $(INTEGRATE_H) $(CPPLIB_H) opts.h $(TREE_FLOW_H) $(TREE_INLINE_H) \
- gt-passes.h $(DF_H) $(PREDICT_H)
+ gt-passes.h $(DF_H) $(PREDICT_H) $(HASHTAB_H)
main.o : main.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TOPLEV_H)
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c (revision 138523)
+++ gcc/tree-cfg.c (working copy)
@@ -6836,7 +6836,7 @@ struct gimple_opt_pass pass_warn_function_return =
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*warn_function_return", /* *notdumped* name */
NULL, /* gate */
execute_warn_function_return, /* execute */
NULL, /* sub */
@@ -6870,7 +6870,7 @@ struct gimple_opt_pass pass_warn_function_noreturn
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*warn_function_noreturn", /* *no-dump* name */
NULL, /* gate */
execute_warn_function_noreturn, /* execute */
NULL, /* sub */
Index: gcc/passes.c
===================================================================
--- gcc/passes.c (revision 138523)
+++ gcc/passes.c (working copy)
@@ -84,6 +84,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-dump.h"
#include "df.h"
#include "predict.h"
+#include "hashtab.h"
#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
#include "dwarf2out.h"
@@ -127,8 +128,28 @@ debug_pass (void)
print_current_pass (stderr);
}
+#if ENABLE_CHECKING
+/* The hashtable mapping passes names to passes, to check that passes
+ are uniquely named */
+static htab_t pass_hash;
+static hashval_t
+hash_pass (const void *p)
+{
+ const struct opt_pass *const pass = (const struct opt_pass *) p;
+ return htab_hash_string((const void*)(pass->name));
+}
+static int
+eq_pass(const void*p1, const void*p2)
+{
+ const struct opt_pass *const pass1 = (const struct opt_pass *) p1;
+ const struct opt_pass *const pass2 = (const struct opt_pass *) p2;
+ return !strcmp(pass1->name, pass2->name);
+}
+
+#endif /*ENABLE_CHECKING*/
+
/* Global variables used to communicate with passes. */
int dump_flags;
bool in_gimple_form;
@@ -288,7 +309,7 @@ struct gimple_opt_pass pass_rest_of_compilation =
{
{
GIMPLE_PASS,
- NULL, /* name */
+ "*rest_of_compilation", /* *no-dump* name */
gate_rest_of_compilation, /* gate */
NULL, /* execute */
NULL, /* sub */
@@ -313,7 +334,7 @@ struct rtl_opt_pass pass_postreload =
{
{
RTL_PASS,
- NULL, /* name */
+ "*postreload", /* *no-dump* name */
gate_postreload, /* gate */
NULL, /* execute */
NULL, /* sub */
@@ -406,7 +427,7 @@ register_dump_files_1 (struct opt_pass *pass, int
int new_properties = (properties | pass->properties_provided)
& ~pass->properties_destroyed;
- if (pass->name && pass->name[0] != '*')
+ if (pass_is_dumpable(pass))
register_one_dump_file (pass);
if (pass->sub)
@@ -443,6 +464,18 @@ register_dump_files (struct opt_pass *pass,int pro
static struct opt_pass **
next_pass_1 (struct opt_pass **list, struct opt_pass *pass)
{
+ gcc_assert(pass != NULL && pass->name != NULL);
+
+#if ENABLE_CHECKING
+ {
+ const void** slot = (const void**)htab_find_slot(pass_hash, (const void*)pass, INSERT);
+ if (*slot && *slot != (const void*)pass)
+ fatal_error("duplicate passes named %s (%p & %p)", pass->name, (void*)pass, *slot);
+ else
+ *slot = (const void*)pass;
+ }
+#endif
+
/* A nonzero static_pass_number indicates that the
pass is already in the list. */
if (pass->static_pass_number)
@@ -502,6 +535,12 @@ init_optimization_passes (void)
{
struct opt_pass **p;
+#if ENABLE_CHECKING
+ /* create the table to check passes' name uniqueness. There are more
+ than two hundred passes, and 347 is prime! */
+ pass_hash = htab_create(347, hash_pass, eq_pass, NULL);
+#endif
+
#define NEXT_PASS(PASS) (p = next_pass_1 (p, &((PASS).pass)))
/* All passes needed to lower the function into shape optimizers can
@@ -1092,7 +1131,7 @@ static bool
pass_init_dump_file (struct opt_pass *pass)
{
/* If a dump file name is present, open it if enabled. */
- if (pass->static_pass_number != -1)
+ if (pass->static_pass_number != -1 && pass_is_dumpable(pass))
{
bool initializing_dump = !dump_initialized_p (pass->static_pass_number);
dump_file_name = get_dump_file_name (pass->static_pass_number);
Index: gcc/cfgrtl.c
===================================================================
--- gcc/cfgrtl.c (revision 138523)
+++ gcc/cfgrtl.c (working copy)
@@ -431,7 +431,7 @@ struct rtl_opt_pass pass_free_cfg =
{
{
RTL_PASS,
- NULL, /* name */
+ "*free-cfg", /* *no-dump* name */
NULL, /* gate */
free_bb_for_insn, /* execute */
NULL, /* sub */
Index: gcc/statistics.c
===================================================================
--- gcc/statistics.c (revision 138523)
+++ gcc/statistics.c (working copy)
@@ -169,7 +169,7 @@ statistics_fini_pass_3 (void **slot, void *data AT
void
statistics_fini_pass (void)
{
- if (current_pass->static_pass_number == -1)
+ if (!pass_is_dumpable(current_pass) || current_pass->static_pass_number == -1)
return;
if (dump_file
Index: gcc/dce.c
===================================================================
--- gcc/dce.c (revision 138523)
+++ gcc/dce.c (working copy)
@@ -446,7 +446,7 @@ struct rtl_opt_pass pass_ud_rtl_dce =
{
{
RTL_PASS,
- "dce", /* name */
+ "ud_dce", /* name */
gate_ud_dce, /* gate */
rest_of_handle_ud_dce, /* execute */
NULL, /* sub */
@@ -831,7 +831,7 @@ struct rtl_opt_pass pass_fast_rtl_dce =
{
{
RTL_PASS,
- "dce", /* name */
+ "fast_dce", /* name */
gate_fast_dce, /* gate */
rest_of_handle_fast_dce, /* execute */
NULL, /* sub */