Commit 9f9ebcdf by Martin Jambor Committed by Martin Jambor

cgraph.c (cgraph_local_info): Call cgraph_get_node instead of…

cgraph.c (cgraph_local_info): Call cgraph_get_node instead of cgraph_node,	handle NULL return value.

2011-04-11  Martin Jambor  <mjambor@suse.cz>

gcc/
	* cgraph.c (cgraph_local_info): Call cgraph_get_node instead
	of cgraph_node,	handle NULL return value.
	(cgraph_global_info): Likewise.
	(cgraph_rtl_info): Likewise.
	* tree-inline.c (estimate_num_insns): Likewise.
	* gimplify.c (unshare_body): Likewise.
	(unvisit_body): Likewise.
	(gimplify_body): Likewise.
	* predict.c (optimize_function_for_size_p): Likewise.
	* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Likewise.
	(call_may_clobber_ref_p_1): Likewise.
	* varasm.c (function_section_1): Likewise.
	(assemble_start_function): Likewise.

gcc/java/
	* decl.c (java_mark_decl_local): Call cgraph_get_node instead of
	cgraph_node and handle returned NULL.

From-SVN: r172258
parent 581985d7
2011-04-11 Martin Jambor <mjambor@suse.cz> 2011-04-11 Martin Jambor <mjambor@suse.cz>
* cgraph.c (cgraph_local_info): Call cgraph_get_node instead
of cgraph_node, handle NULL return value.
(cgraph_global_info): Likewise.
(cgraph_rtl_info): Likewise.
* tree-inline.c (estimate_num_insns): Likewise.
* gimplify.c (unshare_body): Likewise.
(unvisit_body): Likewise.
(gimplify_body): Likewise.
* predict.c (optimize_function_for_size_p): Likewise.
* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Likewise.
(call_may_clobber_ref_p_1): Likewise.
* varasm.c (function_section_1): Likewise.
(assemble_start_function): Likewise.
2011-04-11 Martin Jambor <mjambor@suse.cz>
* except.c (set_nothrow_function_flags): Call cgraph_get_node instead * except.c (set_nothrow_function_flags): Call cgraph_get_node instead
of cgraph_node. of cgraph_node.
* final.c (rest_of_clean_state): Likewise. * final.c (rest_of_clean_state): Likewise.
......
...@@ -1766,7 +1766,9 @@ cgraph_local_info (tree decl) ...@@ -1766,7 +1766,9 @@ cgraph_local_info (tree decl)
struct cgraph_node *node; struct cgraph_node *node;
gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
node = cgraph_node (decl); node = cgraph_get_node (decl);
if (!node)
return NULL;
return &node->local; return &node->local;
} }
...@@ -1778,7 +1780,9 @@ cgraph_global_info (tree decl) ...@@ -1778,7 +1780,9 @@ cgraph_global_info (tree decl)
struct cgraph_node *node; struct cgraph_node *node;
gcc_assert (TREE_CODE (decl) == FUNCTION_DECL && cgraph_global_info_ready); gcc_assert (TREE_CODE (decl) == FUNCTION_DECL && cgraph_global_info_ready);
node = cgraph_node (decl); node = cgraph_get_node (decl);
if (!node)
return NULL;
return &node->global; return &node->global;
} }
...@@ -1790,9 +1794,10 @@ cgraph_rtl_info (tree decl) ...@@ -1790,9 +1794,10 @@ cgraph_rtl_info (tree decl)
struct cgraph_node *node; struct cgraph_node *node;
gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
node = cgraph_node (decl); node = cgraph_get_node (decl);
if (decl != current_function_decl if (!node
&& !TREE_ASM_WRITTEN (node->decl)) || (decl != current_function_decl
&& !TREE_ASM_WRITTEN (node->decl)))
return NULL; return NULL;
return &node->rtl; return &node->rtl;
} }
......
...@@ -959,11 +959,11 @@ copy_if_shared (tree *tp) ...@@ -959,11 +959,11 @@ copy_if_shared (tree *tp)
static void static void
unshare_body (tree *body_p, tree fndecl) unshare_body (tree *body_p, tree fndecl)
{ {
struct cgraph_node *cgn = cgraph_node (fndecl); struct cgraph_node *cgn = cgraph_get_node (fndecl);
copy_if_shared (body_p); copy_if_shared (body_p);
if (body_p == &DECL_SAVED_TREE (fndecl)) if (cgn && body_p == &DECL_SAVED_TREE (fndecl))
for (cgn = cgn->nested; cgn; cgn = cgn->next_nested) for (cgn = cgn->nested; cgn; cgn = cgn->next_nested)
unshare_body (&DECL_SAVED_TREE (cgn->decl), cgn->decl); unshare_body (&DECL_SAVED_TREE (cgn->decl), cgn->decl);
} }
...@@ -1000,11 +1000,11 @@ unmark_visited (tree *tp) ...@@ -1000,11 +1000,11 @@ unmark_visited (tree *tp)
static void static void
unvisit_body (tree *body_p, tree fndecl) unvisit_body (tree *body_p, tree fndecl)
{ {
struct cgraph_node *cgn = cgraph_node (fndecl); struct cgraph_node *cgn = cgraph_get_node (fndecl);
unmark_visited (body_p); unmark_visited (body_p);
if (body_p == &DECL_SAVED_TREE (fndecl)) if (cgn && body_p == &DECL_SAVED_TREE (fndecl))
for (cgn = cgn->nested; cgn; cgn = cgn->next_nested) for (cgn = cgn->nested; cgn; cgn = cgn->next_nested)
unvisit_body (&DECL_SAVED_TREE (cgn->decl), cgn->decl); unvisit_body (&DECL_SAVED_TREE (cgn->decl), cgn->decl);
} }
...@@ -7695,6 +7695,7 @@ gimplify_body (tree *body_p, tree fndecl, bool do_parms) ...@@ -7695,6 +7695,7 @@ gimplify_body (tree *body_p, tree fndecl, bool do_parms)
gimple_seq parm_stmts, seq; gimple_seq parm_stmts, seq;
gimple outer_bind; gimple outer_bind;
struct gimplify_ctx gctx; struct gimplify_ctx gctx;
struct cgraph_node *cgn;
timevar_push (TV_TREE_GIMPLIFY); timevar_push (TV_TREE_GIMPLIFY);
...@@ -7712,7 +7713,8 @@ gimplify_body (tree *body_p, tree fndecl, bool do_parms) ...@@ -7712,7 +7713,8 @@ gimplify_body (tree *body_p, tree fndecl, bool do_parms)
unshare_body (body_p, fndecl); unshare_body (body_p, fndecl);
unvisit_body (body_p, fndecl); unvisit_body (body_p, fndecl);
if (cgraph_node (fndecl)->origin) cgn = cgraph_get_node (fndecl);
if (cgn && cgn->origin)
nonlocal_vlas = pointer_set_create (); nonlocal_vlas = pointer_set_create ();
/* Make sure input_location isn't set to something weird. */ /* Make sure input_location isn't set to something weird. */
......
2011-04-11 Martin Jambor <mjambor@suse.cz>
* decl.c (java_mark_decl_local): Call cgraph_get_node instead of
cgraph_node and handle returned NULL.
2011-03-25 Kai Tietz <ktietz@redhat.com> 2011-03-25 Kai Tietz <ktietz@redhat.com>
* jcf-parse.c (java_read_sourcefilenames): Use filename_cmp * jcf-parse.c (java_read_sourcefilenames): Use filename_cmp
......
...@@ -1928,7 +1928,10 @@ java_mark_decl_local (tree decl) ...@@ -1928,7 +1928,10 @@ java_mark_decl_local (tree decl)
#ifdef ENABLE_CHECKING #ifdef ENABLE_CHECKING
/* Double check that we didn't pass the function to the callgraph early. */ /* Double check that we didn't pass the function to the callgraph early. */
if (TREE_CODE (decl) == FUNCTION_DECL) if (TREE_CODE (decl) == FUNCTION_DECL)
gcc_assert (!cgraph_node (decl)->local.finalized); {
struct cgraph_node *node = cgraph_get_node (decl);
gcc_assert (!node || !node->local.finalized);
}
#endif #endif
gcc_assert (!DECL_RTL_SET_P (decl)); gcc_assert (!DECL_RTL_SET_P (decl));
} }
......
...@@ -214,10 +214,17 @@ probably_never_executed_bb_p (const_basic_block bb) ...@@ -214,10 +214,17 @@ probably_never_executed_bb_p (const_basic_block bb)
bool bool
optimize_function_for_size_p (struct function *fun) optimize_function_for_size_p (struct function *fun)
{ {
return (optimize_size struct cgraph_node *node;
|| (fun && fun->decl
&& (cgraph_node (fun->decl)->frequency if (optimize_size)
== NODE_FREQUENCY_UNLIKELY_EXECUTED))); return true;
if (!fun || !fun->decl)
return false;
node = cgraph_get_node (fun->decl);
if (node && (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED))
return true;
else
return false;
} }
/* Return true when current function should always be optimized for speed. */ /* Return true when current function should always be optimized for speed. */
......
...@@ -3470,10 +3470,11 @@ estimate_num_insns (gimple stmt, eni_weights *weights) ...@@ -3470,10 +3470,11 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
case GIMPLE_CALL: case GIMPLE_CALL:
{ {
tree decl = gimple_call_fndecl (stmt); tree decl = gimple_call_fndecl (stmt);
struct cgraph_node *node;
/* Do not special case builtins where we see the body. /* Do not special case builtins where we see the body.
This just confuse inliner. */ This just confuse inliner. */
if (!decl || cgraph_node (decl)->analyzed) if (!decl || !(node = cgraph_get_node (decl)) || node->analyzed)
; ;
/* For buitins that are likely expanded to nothing or /* For buitins that are likely expanded to nothing or
inlined do not account operand costs. */ inlined do not account operand costs. */
......
...@@ -1245,14 +1245,18 @@ ref_maybe_used_by_call_p_1 (gimple call, ao_ref *ref) ...@@ -1245,14 +1245,18 @@ ref_maybe_used_by_call_p_1 (gimple call, ao_ref *ref)
/* Check if base is a global static variable that is not read /* Check if base is a global static variable that is not read
by the function. */ by the function. */
if (TREE_CODE (base) == VAR_DECL if (callee != NULL_TREE
&& TREE_CODE (base) == VAR_DECL
&& TREE_STATIC (base)) && TREE_STATIC (base))
{ {
struct cgraph_node *node = cgraph_get_node (callee);
bitmap not_read; bitmap not_read;
if (callee != NULL_TREE /* FIXME: Callee can be an OMP builtin that does not have a call graph
&& (not_read node yet. We should enforce that there are nodes for all decls in the
= ipa_reference_get_not_read_global (cgraph_node (callee))) IL and remove this check instead. */
if (node
&& (not_read = ipa_reference_get_not_read_global (node))
&& bitmap_bit_p (not_read, DECL_UID (base))) && bitmap_bit_p (not_read, DECL_UID (base)))
goto process_args; goto process_args;
} }
...@@ -1512,10 +1516,11 @@ call_may_clobber_ref_p_1 (gimple call, ao_ref *ref) ...@@ -1512,10 +1516,11 @@ call_may_clobber_ref_p_1 (gimple call, ao_ref *ref)
&& TREE_CODE (base) == VAR_DECL && TREE_CODE (base) == VAR_DECL
&& TREE_STATIC (base)) && TREE_STATIC (base))
{ {
struct cgraph_node *node = cgraph_get_node (callee);
bitmap not_written; bitmap not_written;
if ((not_written if (node
= ipa_reference_get_not_written_global (cgraph_node (callee))) && (not_written = ipa_reference_get_not_written_global (node))
&& bitmap_bit_p (not_written, DECL_UID (base))) && bitmap_bit_p (not_written, DECL_UID (base)))
return false; return false;
} }
......
...@@ -573,11 +573,14 @@ function_section_1 (tree decl, bool force_cold) ...@@ -573,11 +573,14 @@ function_section_1 (tree decl, bool force_cold)
if (decl) if (decl)
{ {
struct cgraph_node *node = cgraph_node (decl); struct cgraph_node *node = cgraph_get_node (decl);
freq = node->frequency; if (node)
startup = node->only_called_at_startup; {
exit = node->only_called_at_exit; freq = node->frequency;
startup = node->only_called_at_startup;
exit = node->only_called_at_exit;
}
} }
if (force_cold) if (force_cold)
freq = NODE_FREQUENCY_UNLIKELY_EXECUTED; freq = NODE_FREQUENCY_UNLIKELY_EXECUTED;
...@@ -1575,11 +1578,12 @@ assemble_start_function (tree decl, const char *fnname) ...@@ -1575,11 +1578,12 @@ assemble_start_function (tree decl, const char *fnname)
} }
else if (DECL_SECTION_NAME (decl)) else if (DECL_SECTION_NAME (decl))
{ {
struct cgraph_node *node = cgraph_get_node (current_function_decl);
/* Calls to function_section rely on first_function_block_is_cold /* Calls to function_section rely on first_function_block_is_cold
being accurate. */ being accurate. */
first_function_block_is_cold first_function_block_is_cold = (node
= (cgraph_node (current_function_decl)->frequency && node->frequency
== NODE_FREQUENCY_UNLIKELY_EXECUTED); == NODE_FREQUENCY_UNLIKELY_EXECUTED);
} }
in_cold_section_p = first_function_block_is_cold; in_cold_section_p = first_function_block_is_cold;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment