[PATCH 2/5] Existing call graph infrastructure enhancement

Jan Hubicka hubicka@ucw.cz
Wed Sep 24 15:01:00 GMT 2014


> Hi.
> 
> Following patch enhances API functions to be ready for main patch of this patchset.
> 
> Ready for thunk?
> 
> Thank you,
> Martin

> gcc/ChangeLog:
> 
> 2014-09-21  Martin Liška  <mliska@suse.cz>
> 
> 	* cgraph.c (cgraph_node::release_body): New argument keep_arguments
> 	introduced.
> 	* cgraph.h: Likewise.
> 	* cgraphunit.c (cgraph_node::create_wrapper): Usage of new argument introduced.
> 	* ipa-devirt.c (polymorphic_type_binfo_p): Safe check for binfos created by Java.
> 	* tree-ssa-alias.c (ao_ref_base_alias_set): Static function transformed to global.
> 	* tree-ssa-alias.h: Likewise.

> diff --git a/gcc/cgraph.c b/gcc/cgraph.c
> index 8f04284..d40a2922 100644
> --- a/gcc/cgraph.c
> +++ b/gcc/cgraph.c
> @@ -1637,13 +1637,15 @@ release_function_body (tree decl)
>     are free'd in final.c via free_after_compilation().  */
>  
>  void
> -cgraph_node::release_body (void)
> +cgraph_node::release_body (bool keep_arguments)
>  {
>    ipa_transforms_to_apply.release ();
>    if (!used_as_abstract_origin && symtab->state != PARSING)
>      {
>        DECL_RESULT (decl) = NULL;
> -      DECL_ARGUMENTS (decl) = NULL;
> +
> +      if (!keep_arguments)
> +	DECL_ARGUMENTS (decl) = NULL;
>      }
>    /* If the node is abstract and needed, then do not clear DECL_INITIAL
>       of its associated function function declaration because it's
> diff --git a/gcc/cgraph.h b/gcc/cgraph.h
> index a316e40..19ce3b8 100644
> --- a/gcc/cgraph.h
> +++ b/gcc/cgraph.h
> @@ -915,7 +915,7 @@ public:
>       Use this only for functions that are released before being translated to
>       target code (i.e. RTL).  Functions that are compiled to RTL and beyond
>       are free'd in final.c via free_after_compilation().  */
> -  void release_body (void);
> +  void release_body (bool keep_arguments = false);

Please add documentation for KEEP_ARGUMENTS explaining that it is useful only if you want to
rebuild body as thunk.
>  
>    /* cgraph_node is no longer nested function; update cgraph accordingly.  */
>    void unnest (void);
> diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> index 3e3b8d2..c4597e2 100644
> --- a/gcc/cgraphunit.c
> +++ b/gcc/cgraphunit.c
> @@ -2300,7 +2300,7 @@ cgraph_node::create_wrapper (cgraph_node *target)
>      tree decl_result = DECL_RESULT (decl);
>  
>      /* Remove the function's body.  */
I would say Remove the function's body but keep arguments to be reused for thunk.
> -    release_body ();
> +    release_body (true);
>      reset ();
>  
>      DECL_RESULT (decl) = decl_result;
> diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
> index af42c6d..f374933 100644
> --- a/gcc/ipa-devirt.c
> +++ b/gcc/ipa-devirt.c
> @@ -225,7 +225,7 @@ static inline bool
>  polymorphic_type_binfo_p (tree binfo)
>  {
>    /* See if BINFO's type has an virtual table associtated with it.  */
> -  return BINFO_VTABLE (TYPE_BINFO (BINFO_TYPE (binfo)));
> +  return BINFO_TYPE (binfo) && BINFO_VTABLE (TYPE_BINFO (BINFO_TYPE (binfo)));

Aha, this change was for Java, right? Please add comment that Java produces
BINFOs without BINFO_TYPE set.
>  }
>  
>  /* Return TRUE if all derived types of T are known and thus
> diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
> index 442112a..1bf88e2 100644
> --- a/gcc/tree-ssa-alias.c
> +++ b/gcc/tree-ssa-alias.c
> @@ -559,7 +559,7 @@ ao_ref_base (ao_ref *ref)
>  
>  /* Returns the base object alias set of the memory reference *REF.  */
>  
> -static alias_set_type
> +alias_set_type
>  ao_ref_base_alias_set (ao_ref *ref)
>  {
>    tree base_ref;
> diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h
> index 436381a..0d35283 100644
> --- a/gcc/tree-ssa-alias.h
> +++ b/gcc/tree-ssa-alias.h
> @@ -98,6 +98,7 @@ extern void ao_ref_init (ao_ref *, tree);
>  extern void ao_ref_init_from_ptr_and_size (ao_ref *, tree, tree);
>  extern tree ao_ref_base (ao_ref *);
>  extern alias_set_type ao_ref_alias_set (ao_ref *);
> +extern alias_set_type ao_ref_base_alias_set (ao_ref *);

I can not approve this change, but I suppose it is what Richard suggested?

Patch is OK except for the tree-ssa-alias bits.
Honza
>  extern bool ptr_deref_may_alias_global_p (tree);
>  extern bool ptr_derefs_may_alias_p (tree, tree);
>  extern bool ref_may_alias_global_p (tree);



More information about the Gcc-patches mailing list