This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[just for fun] patch to enable SSA inlining
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Dec 2006 03:26:24 +0100
- Subject: [just for fun] patch to enable SSA inlining
Hi,
for those who might be interested, this patch enable SSA inlining on
mainline (needs to be applied on the top of other patches I just sent).
As you notice, IPA passes are currently disabled. It would be great if
authors of the individual passes sent neccesary updates, but if not,
I will fix them one by one once I can fully regtest SSA inliner itself
in all languages.
Honza
Index: tree-pass.h
===================================================================
*** tree-pass.h (revision 120083)
--- tree-pass.h (working copy)
*************** extern struct tree_opt_pass pass_ipa_pur
*** 314,319 ****
--- 314,320 ----
extern struct tree_opt_pass pass_ipa_type_escape;
extern struct tree_opt_pass pass_ipa_pta;
extern struct tree_opt_pass pass_early_local_passes;
+ extern struct tree_opt_pass pass_all_early_optimizations;
extern struct tree_opt_pass pass_all_optimizations;
extern struct tree_opt_pass pass_cleanup_cfg_post_optimizing;
Index: bitmap.c
===================================================================
*** bitmap.c (revision 120083)
--- bitmap.c (working copy)
*************** bitmap_obstack_release (bitmap_obstack *
*** 329,334 ****
--- 329,337 ----
bit_obstack->elements = NULL;
bit_obstack->heads = NULL;
obstack_free (&bit_obstack->obstack, NULL);
+ #ifdef ENABLE_CHECKING
+ memset (&bit_obstack->obstack, 0xab, sizeof (*&bit_obstack->obstack));
+ #endif
}
/* Create a new bitmap on an obstack. If BIT_OBSTACK is NULL, create
Index: tree-optimize.c
===================================================================
*** tree-optimize.c (revision 120083)
--- tree-optimize.c (working copy)
*************** static bool
*** 57,64 ****
gate_all_optimizations (void)
{
return (optimize >= 1
! /* Don't bother doing anything if the program has errors. */
! && !(errorcount || sorrycount));
}
struct tree_opt_pass pass_all_optimizations =
--- 57,65 ----
gate_all_optimizations (void)
{
return (optimize >= 1
! /* Don't bother doing anything if the program has errors.
! We have to pass down the queue if we already went into SSA */
! && (!(errorcount || sorrycount) || gimple_in_ssa_p (cfun)));
}
struct tree_opt_pass pass_all_optimizations =
*************** struct tree_opt_pass pass_all_optimizati
*** 78,87 ****
0 /* letter */
};
struct tree_opt_pass pass_early_local_passes =
{
! NULL, /* name */
! gate_all_optimizations, /* gate */
NULL, /* execute */
NULL, /* sub */
NULL, /* next */
--- 79,129 ----
0 /* letter */
};
+ /* Gate: execute, or not, all of the non-trivial optimizations. */
+
+ static bool
+ gate_all_early_local_passes (void)
+ {
+ return (optimize >= 1
+ /* Don't bother doing anything if the program has errors. */
+ && !(errorcount || sorrycount));
+ }
+
struct tree_opt_pass pass_early_local_passes =
{
! "early_local_cleanups", /* name */
! gate_all_early_local_passes, /* gate */
! NULL, /* 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 */
! 0, /* todo_flags_finish */
! 0 /* letter */
! };
! /* Gate: execute, or not, all of the non-trivial optimizations. */
!
! static bool
! gate_all_early_optimizations (void)
! {
! return (optimize >= 1
! /* Sort of Hack: In non-unit-at-a-time we need to run the early
! optimizations anyway. The early optimization pass is run once
! in IPA queue and once in late local passes. In unit-at-a-time
! the second invocation will get cgraph_global_info_ready. */
! && !cgraph_global_info_ready
! /* Don't bother doing anything if the program has errors. */
! && !(errorcount || sorrycount));
! }
!
! struct tree_opt_pass pass_all_early_optimizations =
! {
! "early_optimizations", /* name */
! gate_all_early_optimizations, /* gate */
NULL, /* execute */
NULL, /* sub */
NULL, /* next */
*************** execute_free_datastructures (void)
*** 170,176 ****
/* Remove the ssa structures. Do it here since this includes statement
annotations that need to be intact during disband_implicit_edges. */
! delete_tree_ssa ();
return 0;
}
--- 212,219 ----
/* Remove the ssa structures. Do it here since this includes statement
annotations that need to be intact during disband_implicit_edges. */
! if (gimple_in_ssa_p (cfun))
! delete_tree_ssa ();
return 0;
}
*************** tree_lowering_passes (tree fn)
*** 368,374 ****
--- 411,420 ----
tree_register_cfg_hooks ();
bitmap_obstack_initialize (NULL);
execute_pass_list (all_lowering_passes);
+ if (cgraph_global_info_ready && optimize)
+ execute_pass_list (pass_all_early_optimizations.sub);
free_dominance_info (CDI_POST_DOMINATORS);
+ free_dominance_info (CDI_DOMINATORS);
compact_blocks ();
current_function_decl = saved_current_function_decl;
bitmap_obstack_release (NULL);
*************** tree_rest_of_compilation (tree fndecl)
*** 408,413 ****
--- 454,462 ----
node = cgraph_node (fndecl);
+ /* Initialize the default bitmap obstack. */
+ bitmap_obstack_initialize (NULL);
+
/* We might need the body of this function so that we can expand
it inline somewhere else. */
if (cgraph_preserve_function_body_p (fndecl))
*************** tree_rest_of_compilation (tree fndecl)
*** 453,461 ****
Kill it so it won't confuse us. */
cgraph_node_remove_callees (node);
-
- /* Initialize the default bitmap obstack. */
- bitmap_obstack_initialize (NULL);
bitmap_obstack_initialize (®_obstack); /* FIXME, only at RTL generation*/
tree_register_cfg_hooks ();
--- 502,507 ----
Index: tree-flow.h
===================================================================
*** tree-flow.h (revision 120089)
--- tree-flow.h (working copy)
*************** struct var_ann_d GTY(())
*** 251,256 ****
--- 251,259 ----
/* True for HEAP and PARM_NOALIAS artificial variables. */
unsigned is_heapvar : 1;
+ /* True for call clobbered variables. */
+ unsigned call_clobbered : 1;
+
/* Memory partition tag assigned to this symbol. */
tree mpt;
Index: passes.c
===================================================================
*** passes.c (revision 120083)
--- passes.c (working copy)
*************** init_optimization_passes (void)
*** 441,452 ****
--- 441,458 ----
p = &all_ipa_passes;
NEXT_PASS (pass_early_ipa_inline);
NEXT_PASS (pass_early_local_passes);
+ /* The process of merging updates of IPA passes to operate on SSA is not
+ complette yet. */
+ #if 0
NEXT_PASS (pass_ipa_cp);
+ #endif
NEXT_PASS (pass_ipa_inline);
+ #if 0
NEXT_PASS (pass_ipa_reference);
NEXT_PASS (pass_ipa_pure_const);
NEXT_PASS (pass_ipa_type_escape);
NEXT_PASS (pass_ipa_pta);
+ #endif
*p = NULL;
/* All passes needed to lower the function into shape optimizers can
*************** init_optimization_passes (void)
*** 467,479 ****
p = &pass_early_local_passes.sub;
NEXT_PASS (pass_tree_profile);
NEXT_PASS (pass_cleanup_cfg);
NEXT_PASS (pass_rebuild_cgraph_edges);
*p = NULL;
p = &all_passes;
NEXT_PASS (pass_fixup_cfg);
- NEXT_PASS (pass_init_datastructures);
- NEXT_PASS (pass_expand_omp);
NEXT_PASS (pass_all_optimizations);
NEXT_PASS (pass_warn_function_noreturn);
NEXT_PASS (pass_mudflap_2);
--- 473,495 ----
p = &pass_early_local_passes.sub;
NEXT_PASS (pass_tree_profile);
NEXT_PASS (pass_cleanup_cfg);
+ NEXT_PASS (pass_init_datastructures);
+ NEXT_PASS (pass_expand_omp);
+ NEXT_PASS (pass_all_early_optimizations);
NEXT_PASS (pass_rebuild_cgraph_edges);
*p = NULL;
+ p = &pass_all_early_optimizations.sub;
+ NEXT_PASS (pass_referenced_vars);
+ NEXT_PASS (pass_reset_cc_flags);
+ NEXT_PASS (pass_create_structure_vars);
+ NEXT_PASS (pass_build_ssa);
+ NEXT_PASS (pass_early_warn_uninitialized);
+
+ *p = NULL;
+
p = &all_passes;
NEXT_PASS (pass_fixup_cfg);
NEXT_PASS (pass_all_optimizations);
NEXT_PASS (pass_warn_function_noreturn);
NEXT_PASS (pass_mudflap_2);
*************** init_optimization_passes (void)
*** 485,494 ****
*p = NULL;
p = &pass_all_optimizations.sub;
- NEXT_PASS (pass_referenced_vars);
- NEXT_PASS (pass_reset_cc_flags);
- NEXT_PASS (pass_create_structure_vars);
- NEXT_PASS (pass_build_ssa);
NEXT_PASS (pass_may_alias);
NEXT_PASS (pass_return_slot);
NEXT_PASS (pass_rename_ssa_copies);
--- 501,506 ----