Cleanup after tree-pass reorg
Jan Hubicka
jh@suse.cz
Thu Mar 20 11:20:00 GMT 2008
Hi,
this followup to the passmanager reorganization cleans up some of remaining mess. The RTL
dump letter infrastructure is dropped from tree-dump.c and I've added some extra sanity checking
to passmanager infrastructure. In particular
- IPA passes can now be subpasses of other IPA passes
- RTL passes can not be subpasses of IPA passes
- IPA pass can not be subpass of GIMPLE or RTL pass.
Bootstrapped/regtested i686-linux.
Honza
* tree-dump.c (dump_enable_all): Remove prototype; do not accept letter argument.
(dump_files): Update.
(enable_rtl_dump_file): Do not accept letter argument.
* tree-pass.h (dump_file_info): Remove letter argument.
* toplev.c (decode_d_option): Update -da handling.
* toplev.h (enable_rtl_dump_file): Update prototype.
* passes.c (register_one_dump_file): Do not accept IPA argument; work it out
based on pass type.
(register_dump_files_1): Likewise.
(init_optimization_passes): Update register_one_dump_file calls.
(execute_one_pass): Sanity check that IPA passes are called at IPA level
and RTL passes at RTL level.
(execute_pass_list): IPA pass can not be after or subpass of GIMPLE/RTL pass.
(execute_ipa_pass_list): Handle IPA subpasses of IPA subpasses and disallov
RTL subpasses of IPA subpasses.
Index: tree-dump.c
===================================================================
*** tree-dump.c (revision 133342)
--- tree-dump.c (working copy)
*************** static void dump_index (dump_info_p, uns
*** 39,45 ****
static void dequeue_and_dump (dump_info_p);
static void dump_new_line (dump_info_p);
static void dump_maybe_newline (dump_info_p);
- static int dump_enable_all (int, int);
/* Add T to the end of the queue of nodes to dump. Returns the index
assigned to T. */
--- 39,44 ----
*************** dump_node (const_tree t, int flags, FILE
*** 782,800 ****
tree_dump_index enumeration in tree-pass.h. */
static struct dump_file_info dump_files[TDI_end] =
{
! {NULL, NULL, NULL, 0, 0, 0, 0},
! {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0, 0, 0},
! {".tu", "translation-unit", NULL, TDF_TREE, 0, 1, 0},
! {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2, 0},
! {".original", "tree-original", NULL, TDF_TREE, 0, 3, 0},
! {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4, 0},
! {".nested", "tree-nested", NULL, TDF_TREE, 0, 5, 0},
! {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6, 0},
#define FIRST_AUTO_NUMBERED_DUMP 7
! {NULL, "tree-all", NULL, TDF_TREE, 0, 0, 0},
! {NULL, "rtl-all", NULL, TDF_RTL, 0, 0, 0},
! {NULL, "ipa-all", NULL, TDF_IPA, 0, 0, 0},
};
/* Dynamically registered tree dump files and switches. */
--- 781,799 ----
tree_dump_index enumeration in tree-pass.h. */
static struct dump_file_info dump_files[TDI_end] =
{
! {NULL, NULL, NULL, 0, 0, 0},
! {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0, 0},
! {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
! {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
! {".original", "tree-original", NULL, TDF_TREE, 0, 3},
! {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
! {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
! {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
#define FIRST_AUTO_NUMBERED_DUMP 7
! {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
! {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
! {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
};
/* Dynamically registered tree dump files and switches. */
*************** dump_end (enum tree_dump_index phase ATT
*** 993,1007 ****
/* Enable all tree dumps. Return number of enabled tree dumps. */
static int
! dump_enable_all (int flags, int letter)
{
int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
int n = 0;
size_t i;
for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
! if ((dump_files[i].flags & ir_dump_type)
! && (letter == 0 || letter == dump_files[i].letter))
{
dump_files[i].state = -1;
dump_files[i].flags |= flags;
--- 992,1005 ----
/* Enable all tree dumps. Return number of enabled tree dumps. */
static int
! dump_enable_all (int flags)
{
int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
int n = 0;
size_t i;
for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
! if ((dump_files[i].flags & ir_dump_type))
{
dump_files[i].state = -1;
dump_files[i].flags |= flags;
*************** dump_enable_all (int flags, int letter)
*** 1009,1016 ****
}
for (i = 0; i < extra_dump_files_in_use; i++)
! if ((extra_dump_files[i].flags & ir_dump_type)
! && (letter == 0 || letter == extra_dump_files[i].letter))
{
extra_dump_files[i].state = -1;
extra_dump_files[i].flags |= flags;
--- 1007,1013 ----
}
for (i = 0; i < extra_dump_files_in_use; i++)
! if ((extra_dump_files[i].flags & ir_dump_type))
{
extra_dump_files[i].state = -1;
extra_dump_files[i].flags |= flags;
*************** dump_switch_p_1 (const char *arg, struct
*** 1075,1081 ****
/* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
known dumps. */
if (dfi->suffix == NULL)
! dump_enable_all (dfi->flags, 0);
return 1;
}
--- 1072,1078 ----
/* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
known dumps. */
if (dfi->suffix == NULL)
! dump_enable_all (dfi->flags);
return 1;
}
*************** dump_function (enum tree_dump_index phas
*** 1122,1133 ****
}
bool
! enable_rtl_dump_file (int letter)
{
! if (letter == 'a')
! letter = 0;
!
! return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, letter) > 0;
}
--- 1119,1127 ----
}
bool
! enable_rtl_dump_file (void)
{
! return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
}
Index: tree-pass.h
===================================================================
*** tree-pass.h (revision 133342)
--- tree-pass.h (working copy)
*************** struct dump_file_info
*** 161,167 ****
int flags; /* user flags */
int state; /* state of play */
int num; /* dump file number */
- int letter; /* enabling letter for RTL dumps */
};
/* Pass properties. */
--- 161,166 ----
Index: toplev.c
===================================================================
*** toplev.c (revision 133342)
--- toplev.c (working copy)
*************** decode_d_option (const char *arg)
*** 1068,1077 ****
case 'H':
setup_core_dumping();
break;
-
case 'a':
default:
- if (!enable_rtl_dump_file (c))
warning (0, "unrecognized gcc debugging option: %c", c);
break;
}
--- 1068,1078 ----
case 'H':
setup_core_dumping();
break;
case 'a':
+ enable_rtl_dump_file ();
+ break;
+
default:
warning (0, "unrecognized gcc debugging option: %c", c);
break;
}
Index: toplev.h
===================================================================
*** toplev.h (revision 133342)
--- toplev.h (working copy)
*************** extern void rest_of_type_compilation (tr
*** 72,78 ****
extern void tree_rest_of_compilation (tree);
extern void init_optimization_passes (void);
extern void finish_optimization_passes (void);
! extern bool enable_rtl_dump_file (int);
extern void announce_function (tree);
--- 72,78 ----
extern void tree_rest_of_compilation (tree);
extern void init_optimization_passes (void);
extern void finish_optimization_passes (void);
! extern bool enable_rtl_dump_file (void);
extern void announce_function (tree);
Index: passes.c
===================================================================
*** passes.c (revision 133342)
--- passes.c (working copy)
*************** struct opt_pass *all_passes, *all_ipa_pa
*** 338,344 ****
enabled or not. */
static void
! register_one_dump_file (struct opt_pass *pass, bool ipa, int properties)
{
char *dot_name, *flag_name, *glob_name;
const char *prefix;
--- 338,344 ----
enabled or not. */
static void
! register_one_dump_file (struct opt_pass *pass)
{
char *dot_name, *flag_name, *glob_name;
const char *prefix;
*************** register_one_dump_file (struct opt_pass
*** 352,360 ****
? 1 : pass->static_pass_number));
dot_name = concat (".", pass->name, num, NULL);
! if (ipa)
prefix = "ipa-", flags = TDF_IPA;
! else if (properties & PROP_trees)
prefix = "tree-", flags = TDF_TREE;
else
prefix = "rtl-", flags = TDF_RTL;
--- 352,360 ----
? 1 : pass->static_pass_number));
dot_name = concat (".", pass->name, num, NULL);
! if (pass->type == SIMPLE_IPA_PASS)
prefix = "ipa-", flags = TDF_IPA;
! else if (pass->type == GIMPLE_PASS)
prefix = "tree-", flags = TDF_TREE;
else
prefix = "rtl-", flags = TDF_RTL;
*************** register_one_dump_file (struct opt_pass
*** 368,374 ****
/* Recursive worker function for register_dump_files. */
static int
! register_dump_files_1 (struct opt_pass *pass, bool ipa, int properties)
{
do
{
--- 368,374 ----
/* Recursive worker function for register_dump_files. */
static int
! register_dump_files_1 (struct opt_pass *pass, int properties)
{
do
{
*************** register_dump_files_1 (struct opt_pass *
*** 376,386 ****
& ~pass->properties_destroyed;
if (pass->name)
! register_one_dump_file (pass, ipa, new_properties);
if (pass->sub)
! new_properties = register_dump_files_1 (pass->sub, false,
! new_properties);
/* If we have a gate, combine the properties that we could have with
and without the pass being examined. */
--- 376,385 ----
& ~pass->properties_destroyed;
if (pass->name)
! register_one_dump_file (pass);
if (pass->sub)
! new_properties = register_dump_files_1 (pass->sub, new_properties);
/* If we have a gate, combine the properties that we could have with
and without the pass being examined. */
*************** register_dump_files_1 (struct opt_pass *
*** 396,411 ****
return properties;
}
! /* Register the dump files for the pipeline starting at PASS. IPA is
! true if the pass is inter-procedural, and PROPERTIES reflects the
! properties that are guaranteed to be available at the beginning of
! the pipeline. */
static void
! register_dump_files (struct opt_pass *pass, bool ipa, int properties)
{
pass->properties_required |= properties;
! register_dump_files_1 (pass, ipa, properties);
}
/* Add a pass to the pass list. Duplicate the pass if it's already
--- 395,409 ----
return properties;
}
! /* Register the dump files for the pipeline starting at PASS.
! PROPERTIES reflects the properties that are guaranteed to be available at
! the beginning of the pipeline. */
static void
! register_dump_files (struct opt_pass *pass,int properties)
{
pass->properties_required |= properties;
! register_dump_files_1 (pass, properties);
}
/* Add a pass to the pass list. Duplicate the pass if it's already
*************** init_optimization_passes (void)
*** 793,804 ****
#undef NEXT_PASS
/* Register the passes with the tree dump code. */
! register_dump_files (all_lowering_passes, false, PROP_gimple_any);
all_lowering_passes->todo_flags_start |= TODO_set_props;
! register_dump_files (all_ipa_passes, true,
PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
| PROP_cfg);
! register_dump_files (all_passes, false,
PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
| PROP_cfg);
}
--- 791,802 ----
#undef NEXT_PASS
/* Register the passes with the tree dump code. */
! register_dump_files (all_lowering_passes, PROP_gimple_any);
all_lowering_passes->todo_flags_start |= TODO_set_props;
! register_dump_files (all_ipa_passes,
PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
| PROP_cfg);
! register_dump_files (all_passes,
PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh
| PROP_cfg);
}
*************** execute_one_pass (struct opt_pass *pass)
*** 1071,1076 ****
--- 1069,1085 ----
bool initializing_dump;
unsigned int todo_after = 0;
+ /* IPA passes are executed on whole program, so cfun should be NULL.
+ Ohter passes needs function context set. */
+ if (pass->type == SIMPLE_IPA_PASS)
+ gcc_assert (!cfun && !current_function_decl);
+ else
+ {
+ gcc_assert (cfun && current_function_decl);
+ gcc_assert (!(cfun->curr_properties & PROP_trees)
+ || pass->type != RTL_PASS);
+ }
+
current_pass = pass;
/* See if we're supposed to run this pass. */
if (pass->gate && !pass->gate ())
*************** execute_pass_list (struct opt_pass *pass
*** 1177,1182 ****
--- 1186,1193 ----
{
do
{
+ gcc_assert (pass->type == GIMPLE_PASS
+ || pass->type == RTL_PASS);
if (execute_one_pass (pass) && pass->sub)
execute_pass_list (pass->sub);
pass = pass->next;
*************** execute_ipa_pass_list (struct opt_pass *
*** 1193,1201 ****
{
gcc_assert (!current_function_decl);
gcc_assert (!cfun);
if (execute_one_pass (pass) && pass->sub)
! do_per_function_toporder ((void (*)(void *))execute_pass_list,
! pass->sub);
if (!current_function_decl)
cgraph_process_new_functions ();
pass = pass->next;
--- 1204,1220 ----
{
gcc_assert (!current_function_decl);
gcc_assert (!cfun);
+ gcc_assert (pass->type == SIMPLE_IPA_PASS);
if (execute_one_pass (pass) && pass->sub)
! {
! if (pass->sub->type == GIMPLE_PASS)
! do_per_function_toporder ((void (*)(void *))execute_pass_list,
! pass->sub);
! else if (pass->sub->type == SIMPLE_IPA_PASS)
! execute_ipa_pass_list (pass->sub);
! else
! gcc_unreachable ();
! }
if (!current_function_decl)
cgraph_process_new_functions ();
pass = pass->next;
More information about the Gcc-patches
mailing list