summaryrefslogtreecommitdiff
path: root/gcc/cgraphbuild.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2007-02-09 22:49:30 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2007-02-09 22:49:30 +0000
commit4ae20857c0da0cab2fbed33d10d6b4d504aa9862 (patch)
treedd0cf0d6f5ee79e534f85b6bf4b3b2f75372bd8c /gcc/cgraphbuild.c
parent9a6f4ddd99aa5db1bed9cfb733d52515f5e131af (diff)
downloadgcc-4ae20857c0da0cab2fbed33d10d6b4d504aa9862.tar.gz
* Makefile.in (passes.o, ipa-inline.o): Add dependencies.
* cgraphbuild.c (build_cgraph_edges): Compute frequencies. (rebuild_cgraph_edges): Likewise. * cgraph.c (cgraph_set_call_stmt): Add new argument frequency. (dump_cgraph_node): Dump frequencies. (cgraph_clone_edge): Add frequency scales. (cgraph_clone_node): Add freuqnecy. * cgraph.h (cgraph_edge): Add freuqnecy argument. (CGRAPH_FREQ_BASE, CGRAPH_FREQ_MAX): New constants. (cgraph_create_edge, cgraph_clone_edge, cgraph_clone_node): Update. * tree-pass.h (TODO_rebuild_frequencies): New constant. * cgraphunit.c (verify_cgraph_node): Verify frequencies. (cgraph_copy_node_for_versioning): Update call of cgraph_clone_edge. (save_inline_function_body): Likewise. * ipa-inline.c: inluce rtl.h (cgraph_clone_inlined_nods): Update call of cgraph_clone_node. (cgraph_edge_badness): Use frequencies. (cgraph_decide_recursive_inlining): Update clonning. (cgraph_decide_inlining_of_small_function): Dump frequency. * predict.c (estimate_bb_frequencies): Export. * predict.h (estimate_bb_frequencies): Declare. * tree-inline.c (copy_bb): Watch overflows. (expand_call_inline): Update call of cgraph_create_edge. (optimize_inline_calls): Use TODO flags to update frequnecies. * passes.h: Include predict.h (init_optimization_passes): Move profile ahead. (execute_function_todo): Handle TODO_rebuild_frequencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121780 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cgraphbuild.c')
-rw-r--r--gcc/cgraphbuild.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/gcc/cgraphbuild.c b/gcc/cgraphbuild.c
index a2df564aa65..9d89aeb8d01 100644
--- a/gcc/cgraphbuild.c
+++ b/gcc/cgraphbuild.c
@@ -115,6 +115,10 @@ build_cgraph_edges (void)
struct pointer_set_t *visited_nodes = pointer_set_create ();
block_stmt_iterator bsi;
tree step;
+ int entry_freq = ENTRY_BLOCK_PTR->frequency;
+
+ if (!entry_freq)
+ entry_freq = 1;
/* Create the callgraph edges and record the nodes referenced by the function.
body. */
@@ -127,8 +131,12 @@ build_cgraph_edges (void)
if (call && (decl = get_callee_fndecl (call)))
{
+ int freq = (!bb->frequency && !entry_freq ? CGRAPH_FREQ_BASE
+ : bb->frequency * CGRAPH_FREQ_BASE / entry_freq);
+ if (freq > CGRAPH_FREQ_MAX)
+ freq = CGRAPH_FREQ_MAX;
cgraph_create_edge (node, cgraph_node (decl), stmt,
- bb->count,
+ bb->count, freq,
bb->loop_depth);
walk_tree (&TREE_OPERAND (call, 1),
record_reference, node, visited_nodes);
@@ -196,6 +204,10 @@ rebuild_cgraph_edges (void)
basic_block bb;
struct cgraph_node *node = cgraph_node (current_function_decl);
block_stmt_iterator bsi;
+ int entry_freq = ENTRY_BLOCK_PTR->frequency;
+
+ if (!entry_freq)
+ entry_freq = 1;
cgraph_node_remove_callees (node);
@@ -209,9 +221,14 @@ rebuild_cgraph_edges (void)
tree decl;
if (call && (decl = get_callee_fndecl (call)))
- cgraph_create_edge (node, cgraph_node (decl), stmt,
- bb->count,
- bb->loop_depth);
+ {
+ int freq = (!bb->frequency && !entry_freq ? CGRAPH_FREQ_BASE
+ : bb->frequency * CGRAPH_FREQ_BASE / entry_freq);
+ if (freq > CGRAPH_FREQ_MAX)
+ freq = CGRAPH_FREQ_MAX;
+ cgraph_create_edge (node, cgraph_node (decl), stmt,
+ bb->count, freq, bb->loop_depth);
+ }
}
initialize_inline_failed (node);
gcc_assert (!node->global.inlined_to);