On Wed, 17 Jan 2018, Jakub Jelinek wrote:

> Hi!
> 
> PR83882 complains that PR81715 testcase fails on callee copies parameter
> targets.  The following patch ought to fix that, but I have only
> bootstrapped/regtested it on x86_64-linux and i686-linux + on the testcase
> with hppa.

Looks reasonable.

> John, do you think you could test this on hppa without the callee copies
> default change?
> 
> Or should we not care anymore if there aren't any similar targets left?

How's that communicated to the middle-end anyways?

Richard.

> 2018-01-17  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR sanitizer/81715
>       PR testsuite/83882
>       * function.h (gimplify_parameters): Add gimple_seq * argument.
>       * function.c: Include gimple.h and options.h.
>       (gimplify_parameters): Add cleanup argument, add CLOBBER stmts
>       for the added local temporaries if needed.
>       * gimplify.c (gimplify_body): Adjust gimplify_parameters caller,
>       if there are any parameter cleanups, wrap whole body into a
>       try/finally with the cleanups.
> 
> --- gcc/function.h.jj 2018-01-03 10:19:53.858533740 +0100
> +++ gcc/function.h    2018-01-16 14:31:21.409972177 +0100
> @@ -607,7 +607,7 @@ extern bool initial_value_entry (int i,
>  extern void instantiate_decl_rtl (rtx x);
>  extern int aggregate_value_p (const_tree, const_tree);
>  extern bool use_register_for_decl (const_tree);
> -extern gimple_seq gimplify_parameters (void);
> +extern gimple_seq gimplify_parameters (gimple_seq *);
>  extern void locate_and_pad_parm (machine_mode, tree, int, int, int,
>                                tree, struct args_size *,
>                                struct locate_and_pad_arg_data *);
> --- gcc/function.c.jj 2018-01-12 11:35:48.901222595 +0100
> +++ gcc/function.c    2018-01-16 15:13:22.165665047 +0100
> @@ -79,6 +79,8 @@ along with GCC; see the file COPYING3.
>  #include "tree-ssa.h"
>  #include "stringpool.h"
>  #include "attribs.h"
> +#include "gimple.h"
> +#include "options.h"
>  
>  /* So we can assign to cfun in this file.  */
>  #undef cfun
> @@ -3993,7 +3995,7 @@ gimplify_parm_type (tree *tp, int *walk_
>     statements to add to the beginning of the function.  */
>  
>  gimple_seq
> -gimplify_parameters (void)
> +gimplify_parameters (gimple_seq *cleanup)
>  {
>    struct assign_parm_data_all all;
>    tree parm;
> @@ -4058,6 +4060,16 @@ gimplify_parameters (void)
>                 else if (TREE_CODE (type) == COMPLEX_TYPE
>                          || TREE_CODE (type) == VECTOR_TYPE)
>                   DECL_GIMPLE_REG_P (local) = 1;
> +
> +               if (!is_gimple_reg (local)
> +                   && flag_stack_reuse != SR_NONE)
> +                 {
> +                   tree clobber = build_constructor (type, NULL);
> +                   gimple *clobber_stmt;
> +                   TREE_THIS_VOLATILE (clobber) = 1;
> +                   clobber_stmt = gimple_build_assign (local, clobber);
> +                   gimple_seq_add_stmt (cleanup, clobber_stmt);
> +                 }
>               }
>             else
>               {
> --- gcc/gimplify.c.jj 2018-01-16 12:21:15.895859416 +0100
> +++ gcc/gimplify.c    2018-01-16 14:41:27.643872081 +0100
> @@ -12589,7 +12589,7 @@ gbind *
>  gimplify_body (tree fndecl, bool do_parms)
>  {
>    location_t saved_location = input_location;
> -  gimple_seq parm_stmts, seq;
> +  gimple_seq parm_stmts, parm_cleanup = NULL, seq;
>    gimple *outer_stmt;
>    gbind *outer_bind;
>    struct cgraph_node *cgn;
> @@ -12628,7 +12628,7 @@ gimplify_body (tree fndecl, bool do_parm
>  
>    /* Resolve callee-copies.  This has to be done before processing
>       the body so that DECL_VALUE_EXPR gets processed correctly.  */
> -  parm_stmts = do_parms ? gimplify_parameters () : NULL;
> +  parm_stmts = do_parms ? gimplify_parameters (&parm_cleanup) : NULL;
>  
>    /* Gimplify the function's body.  */
>    seq = NULL;
> @@ -12657,6 +12657,13 @@ gimplify_body (tree fndecl, bool do_parm
>        tree parm;
>  
>        gimplify_seq_add_seq (&parm_stmts, gimple_bind_body (outer_bind));
> +      if (parm_cleanup)
> +     {
> +       gtry *g = gimple_build_try (parm_stmts, parm_cleanup,
> +                                   GIMPLE_TRY_FINALLY);
> +       parm_stmts = NULL;
> +       gimple_seq_add_stmt (&parm_stmts, g);
> +     }
>        gimple_bind_set_body (outer_bind, parm_stmts);
>  
>        for (parm = DECL_ARGUMENTS (current_function_decl);
> 
>       Jakub
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)

Reply via email to