On Tue, Oct 6, 2015 at 1:43 PM, H.J. Lu <hongjiu...@intel.com> wrote:
> Since targetm.expand_to_rtl_hook may be called to switch ABI, it should
> be called for each function before expanding to RTL.  Otherwise, we may
> use the stale information from compilation of the previous function.
> aggregate_value_p uses call_used_regs.  aggregate_value_p is used by
> IPA and return value optimization, which are called before
> pass_expand::execute after RTL expansion starts.  We need to call
> targetm.expand_to_rtl_hook early enough in cgraph_node::expand to make
> sure that everything is in sync when RTL expansion starts.
>
> Tested on Linux/x86-64.  OK for trunk?

Hmm, I think set_cfun hook should handle this.  expand_to_rtl_hook shouldn't
mess with per-function stuff.

Richard.

>
> H.J.
> ---
>         PR middle-end/67850
>         * cfgexpand.c (pass_expand::execute): Don't call
>         targetm.expand_to_rtl_hook here.
>         * cgraphunit.c (cgraph_node::expand): Call
>         targetm.expand_to_rtl_hook here.
> ---
>  gcc/cfgexpand.c  | 1 -
>  gcc/cgraphunit.c | 3 +++
>  2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
> index 58e55d2..6891750 100644
> --- a/gcc/cfgexpand.c
> +++ b/gcc/cfgexpand.c
> @@ -6150,7 +6150,6 @@ pass_expand::execute (function *fun)
>    /* Mark arrays indexed with non-constant indices with TREE_ADDRESSABLE.  */
>    discover_nonconstant_array_refs ();
>
> -  targetm.expand_to_rtl_hook ();
>    crtl->stack_alignment_needed = STACK_BOUNDARY;
>    crtl->max_used_stack_slot_alignment = STACK_BOUNDARY;
>    crtl->stack_alignment_estimated = 0;
> diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> index 04a4d3f..537a089 100644
> --- a/gcc/cgraphunit.c
> +++ b/gcc/cgraphunit.c
> @@ -1973,6 +1973,9 @@ cgraph_node::expand (void)
>
>    bitmap_obstack_initialize (&reg_obstack); /* FIXME, only at RTL 
> generation*/
>
> +  /* It may update call_used_regs, which is used by aggregate_value_p.  */
> +  targetm.expand_to_rtl_hook ();
> +
>    execute_all_ipa_transforms ();
>
>    /* Perform all tree transforms and optimizations.  */
> --
> 2.4.3
>

Reply via email to