This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/7] cgraph_node -> cgraph_get_node conversions accepting NULL results


Hi,

On Mon, Apr 11, 2011 at 12:18:24PM +0200, Jan Hubicka wrote:
> > 2011-04-06  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.
> 
> OK.

Thnanks! I'm in the process of re-bootstrapping and will start
committing the patches soon.

However...

> > Index: src/gcc/predict.c
> > ===================================================================
> > --- src.orig/gcc/predict.c
> > +++ src/gcc/predict.c
> > @@ -214,10 +214,11 @@ probably_never_executed_bb_p (const_basi
> >  bool
> >  optimize_function_for_size_p (struct function *fun)
> >  {
> > +  struct cgraph_node *node;
> >    return (optimize_size
> >  	  || (fun && fun->decl
> > -	      && (cgraph_node (fun->decl)->frequency
> > -		  == NODE_FREQUENCY_UNLIKELY_EXECUTED)));
> > +	      && (node = cgraph_get_node (fun->decl))
> > +	      && (node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED)));
> 
> I guess this is because optimize_function_for_size_p is used from folder
> that in turn is called before cgraph is built.
>  Please, for consistency, add same
> test into the other predicates that calls cgraph_node (fun->decl) here

...there are no such places in in predict.c, the other two calls
to cgraph_(get_)node pass current_function_decl to the function.
Or did you mean some other file?

> and also uwind the statement into series of ifs.  It has grown in to
> quite a beast.  This is preaproved either as this patch of followup.

OK, I've turned the body of the predicate into:

/* Return true when current function should always be optimized for size.  */

bool
optimize_function_for_size_p (struct function *fun)
{
  struct cgraph_node *node;

  if (optimize_size)
    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;
}


Thanks,

Martin



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]