diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-08 11:13:14 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-08 11:13:14 +0000 |
commit | f37a500840527ce3a068813b04b57ccfca23a20f (patch) | |
tree | 5658297c549eec3a1a45febe1d3d11e413cc482c /gcc/ipa.c | |
parent | 85eb3cd7157d1eeab1222c32130974cb3c3ab83f (diff) | |
download | gcc-f37a500840527ce3a068813b04b57ccfca23a20f.tar.gz |
* tree-pas.h (TODO_remove_function): New flag.
(TODO_update*): Renumber.
(pass_ipa_increase_alignment,
pass_ipa_function_and_variable_visibility): New passes.
* cgraphunit.c (cgraph_increase_alignment): Move to tree-vectorizer.c
(cgraph_function_and_variable_visibility): Move to ipa.c
(cgraph_optimize): Don't call cgraph_function_and_variable_visibility,
cgraph_increase_alignment.
* ipa-inline.c (cgraph_decide_inlining): Don't push timevar.
(cgraph_decide_inlining_incrementally): Push TV_INTEGRATION before
calling tree-inline.
(cgraph_early_inlining): Do not call cgraph_remove_unreachable_nodes.
(pass_ipa_inline, pass_early_ipa_inlining): Set TODO_remove_functions
* tree-vectorizer.c (increase_alignment): Move here from cgraphunit.c
(gate_increase_alignment): New function.
(pass_ipa_increase_alignment): New pass.
* ipa.c: Inline tree-pass.h and timevar.h
(function_and_variable_visibility): Move here from cgraphunit.c
* tree-optimize.c (pass_early_local_passes): Add TODO_remove_functions.
* passes.c (init_optimization_passes): Add the two new passes.
(execute_todo): Handle cgraph_remove_functions.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120576 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ipa.c')
-rw-r--r-- | gcc/ipa.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/gcc/ipa.c b/gcc/ipa.c index f45c0583876..68e65a9e80c 100644 --- a/gcc/ipa.c +++ b/gcc/ipa.c @@ -23,6 +23,8 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #include "coretypes.h" #include "tm.h" #include "cgraph.h" +#include "tree-pass.h" +#include "timevar.h" /* Fill array order with all nodes with output flag set in the reverse topological order. */ @@ -206,3 +208,85 @@ cgraph_remove_unreachable_nodes (bool before_inlining_p, FILE *file) fprintf (file, "\nReclaimed %i insns", insns); return changed; } + +/* Mark visibility of all functions. + + A local function is one whose calls can occur only in the current + compilation unit and all its calls are explicit, so we can change + its calling convention. We simply mark all static functions whose + address is not taken as local. + + We also change the TREE_PUBLIC flag of all declarations that are public + in language point of view but we want to overwrite this default + via visibilities for the backend point of view. */ + +static void +function_and_variable_visibility (void) +{ + struct cgraph_node *node; + struct varpool_node *vnode; + + for (node = cgraph_nodes; node; node = node->next) + { + if (node->reachable + && (DECL_COMDAT (node->decl) + || (!flag_whole_program + && TREE_PUBLIC (node->decl) && !DECL_EXTERNAL (node->decl)))) + node->local.externally_visible = true; + if (!node->local.externally_visible && node->analyzed + && !DECL_EXTERNAL (node->decl)) + { + gcc_assert (flag_whole_program || !TREE_PUBLIC (node->decl)); + TREE_PUBLIC (node->decl) = 0; + } + node->local.local = (!node->needed + && node->analyzed + && !DECL_EXTERNAL (node->decl) + && !node->local.externally_visible); + } + for (vnode = varpool_nodes_queue; vnode; vnode = vnode->next_needed) + { + if (vnode->needed + && !flag_whole_program + && (DECL_COMDAT (vnode->decl) || TREE_PUBLIC (vnode->decl))) + vnode->externally_visible = 1; + if (!vnode->externally_visible) + { + gcc_assert (flag_whole_program || !TREE_PUBLIC (vnode->decl)); + TREE_PUBLIC (vnode->decl) = 0; + } + gcc_assert (TREE_STATIC (vnode->decl)); + } + + if (dump_file) + { + fprintf (dump_file, "\nMarking local functions:"); + for (node = cgraph_nodes; node; node = node->next) + if (node->local.local) + fprintf (dump_file, " %s", cgraph_node_name (node)); + fprintf (dump_file, "\n\n"); + fprintf (dump_file, "\nMarking externally visible functions:"); + for (node = cgraph_nodes; node; node = node->next) + if (node->local.externally_visible) + fprintf (dump_file, " %s", cgraph_node_name (node)); + fprintf (dump_file, "\n\n"); + } + cgraph_function_flags_ready = true; +} + +struct tree_opt_pass pass_ipa_function_and_variable_visibility = +{ + "visibility", /* name */ + NULL, /* gate */ + function_and_variable_visibility, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + TV_CGRAPHOPT, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_remove_functions | TODO_dump_cgraph,/* todo_flags_finish */ + 0 /* letter */ +}; |