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] Use build_clobber some more


On Thu, 26 Sep 2019, Jakub Jelinek wrote:

> Hi!
> 
> I wasn't aware of this new build_clobber function added last year,
> apparently we have still tons of spots that build clobbers by hand and using
> build_clobber will make it clear what we are actually building.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Richard.

> 2019-09-26  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* function.c (gimplify_parameters): Use build_clobber function.
> 	* tree-ssa.c (execute_update_addresses_taken): Likewise.
> 	* tree-inline.c (expand_call_inline): Likewise.
> 	* tree-sra.c (clobber_subtree): Likewise.
> 	* tree-ssa-ccp.c (insert_clobber_before_stack_restore): Likewise.
> 	* omp-low.c (lower_rec_simd_input_clauses, lower_rec_input_clauses,
> 	lower_omp_single, lower_depend_clauses, lower_omp_taskreg,
> 	lower_omp_target): Likewise.
> 	* omp-expand.c (expand_omp_for_generic): Likewise.
> 	* omp-offload.c (ompdevlow_adjust_simt_enter): Likewise.
> 
> --- gcc/function.c.jj	2019-09-11 10:27:40.170772183 +0200
> +++ gcc/function.c	2019-09-25 18:22:43.414133650 +0200
> @@ -3892,9 +3892,8 @@ gimplify_parameters (gimple_seq *cleanup
>  		  if (!is_gimple_reg (local)
>  		      && flag_stack_reuse != SR_NONE)
>  		    {
> -		      tree clobber = build_constructor (type, NULL);
> +		      tree clobber = build_clobber (type);
>  		      gimple *clobber_stmt;
> -		      TREE_THIS_VOLATILE (clobber) = 1;
>  		      clobber_stmt = gimple_build_assign (local, clobber);
>  		      gimple_seq_add_stmt (cleanup, clobber_stmt);
>  		    }
> --- gcc/tree-ssa.c.jj	2019-07-19 11:56:10.438964997 +0200
> +++ gcc/tree-ssa.c	2019-09-25 18:24:27.077559222 +0200
> @@ -2016,9 +2016,7 @@ execute_update_addresses_taken (void)
>  			    /* In ASAN_MARK (UNPOISON, &b, ...) the variable
>  			       is uninitialized.  Avoid dependencies on
>  			       previous out of scope value.  */
> -			    tree clobber
> -			      = build_constructor (TREE_TYPE (var), NULL);
> -			    TREE_THIS_VOLATILE (clobber) = 1;
> +			    tree clobber = build_clobber (TREE_TYPE (var));
>  			    gimple *g = gimple_build_assign (var, clobber);
>  			    gsi_replace (&gsi, g, GSI_SAME_STMT);
>  			  }
> --- gcc/tree-inline.c.jj	2019-09-20 12:25:48.187387060 +0200
> +++ gcc/tree-inline.c	2019-09-25 18:23:35.633340550 +0200
> @@ -5016,9 +5016,8 @@ expand_call_inline (basic_block bb, gimp
>  	  tree *varp = id->decl_map->get (p);
>  	  if (varp && VAR_P (*varp) && !is_gimple_reg (*varp))
>  	    {
> -	      tree clobber = build_constructor (TREE_TYPE (*varp), NULL);
> +	      tree clobber = build_clobber (TREE_TYPE (*varp));
>  	      gimple *clobber_stmt;
> -	      TREE_THIS_VOLATILE (clobber) = 1;
>  	      clobber_stmt = gimple_build_assign (*varp, clobber);
>  	      gimple_set_location (clobber_stmt, gimple_location (stmt));
>  	      gsi_insert_before (&stmt_gsi, clobber_stmt, GSI_SAME_STMT);
> @@ -5086,9 +5085,8 @@ expand_call_inline (basic_block bb, gimp
>  	  && !is_gimple_reg (id->retvar)
>  	  && !stmt_ends_bb_p (stmt))
>  	{
> -	  tree clobber = build_constructor (TREE_TYPE (id->retvar), NULL);
> +	  tree clobber = build_clobber (TREE_TYPE (id->retvar));
>  	  gimple *clobber_stmt;
> -	  TREE_THIS_VOLATILE (clobber) = 1;
>  	  clobber_stmt = gimple_build_assign (id->retvar, clobber);
>  	  gimple_set_location (clobber_stmt, gimple_location (old_stmt));
>  	  gsi_insert_after (&stmt_gsi, clobber_stmt, GSI_SAME_STMT);
> @@ -5134,9 +5132,8 @@ expand_call_inline (basic_block bb, gimp
>  	       && !TREE_THIS_VOLATILE (id->retvar)
>  	       && !is_gimple_reg (id->retvar))
>  	{
> -	  tree clobber = build_constructor (TREE_TYPE (id->retvar), NULL);
> +	  tree clobber = build_clobber (TREE_TYPE (id->retvar));
>  	  gimple *clobber_stmt;
> -	  TREE_THIS_VOLATILE (clobber) = 1;
>  	  clobber_stmt = gimple_build_assign (id->retvar, clobber);
>  	  gimple_set_location (clobber_stmt, gimple_location (stmt));
>  	  gsi_replace (&stmt_gsi, clobber_stmt, false);
> --- gcc/tree-sra.c.jj	2019-09-20 12:25:46.832408059 +0200
> +++ gcc/tree-sra.c	2019-09-25 18:23:59.899971991 +0200
> @@ -3039,8 +3039,7 @@ clobber_subtree (struct access *access,
>    if (access->grp_to_be_replaced)
>      {
>        tree rep = get_access_replacement (access);
> -      tree clobber = build_constructor (access->type, NULL);
> -      TREE_THIS_VOLATILE (clobber) = 1;
> +      tree clobber = build_clobber (access->type);
>        gimple *stmt = gimple_build_assign (rep, clobber);
>  
>        if (insert_after)
> --- gcc/tree-ssa-ccp.c.jj	2019-09-24 14:39:04.685508253 +0200
> +++ gcc/tree-ssa-ccp.c	2019-09-25 18:24:51.572187200 +0200
> @@ -2093,9 +2093,7 @@ insert_clobber_before_stack_restore (tre
>    FOR_EACH_IMM_USE_STMT (stmt, iter, saved_val)
>      if (gimple_call_builtin_p (stmt, BUILT_IN_STACK_RESTORE))
>        {
> -	clobber = build_constructor (TREE_TYPE (var),
> -				     NULL);
> -	TREE_THIS_VOLATILE (clobber) = 1;
> +	clobber = build_clobber (TREE_TYPE (var));
>  	clobber_stmt = gimple_build_assign (var, clobber);
>  
>  	i = gsi_for_stmt (stmt);
> --- gcc/omp-low.c.jj	2019-08-08 08:37:11.280830708 +0200
> +++ gcc/omp-low.c	2019-09-25 18:26:21.761817417 +0200
> @@ -4044,8 +4044,7 @@ lower_rec_simd_input_clauses (tree new_v
>        DECL_ATTRIBUTES (ivar) = tree_cons (get_identifier ("omp simt private"),
>  					  NULL, DECL_ATTRIBUTES (ivar));
>        sctx->simt_eargs.safe_push (build1 (ADDR_EXPR, ptype, ivar));
> -      tree clobber = build_constructor (type, NULL);
> -      TREE_THIS_VOLATILE (clobber) = 1;
> +      tree clobber = build_clobber (type);
>        gimple *g = gimple_build_assign (ivar, clobber);
>        gimple_seq_add_stmt (&sctx->simt_dlist, g);
>      }
> @@ -5939,8 +5938,7 @@ lower_rec_input_clauses (tree clauses, g
>      }
>    if (tskred_avar)
>      {
> -      tree clobber = build_constructor (TREE_TYPE (tskred_avar), NULL);
> -      TREE_THIS_VOLATILE (clobber) = 1;
> +      tree clobber = build_clobber (TREE_TYPE (tskred_avar));
>        gimple_seq_add_stmt (ilist, gimple_build_assign (tskred_avar, clobber));
>      }
>  
> @@ -7896,8 +7894,7 @@ lower_omp_single (gimple_stmt_iterator *
>    if (ctx->record_type)
>      {
>        gimple_stmt_iterator gsi = gsi_start (bind_body_tail);
> -      tree clobber = build_constructor (ctx->record_type, NULL);
> -      TREE_THIS_VOLATILE (clobber) = 1;
> +      tree clobber = build_clobber (ctx->record_type);
>        gsi_insert_after (&gsi, gimple_build_assign (ctx->sender_decl,
>  						   clobber), GSI_SAME_STMT);
>      }
> @@ -11029,8 +11026,7 @@ lower_depend_clauses (tree *pclauses, gi
>    OMP_CLAUSE_DECL (c) = build_fold_addr_expr (array);
>    OMP_CLAUSE_CHAIN (c) = *pclauses;
>    *pclauses = c;
> -  tree clobber = build_constructor (type, NULL);
> -  TREE_THIS_VOLATILE (clobber) = 1;
> +  tree clobber = build_clobber (type);
>    g = gimple_build_assign (array, clobber);
>    gimple_seq_add_stmt (oseq, g);
>  }
> @@ -11165,8 +11161,7 @@ lower_omp_taskreg (gimple_stmt_iterator
>  
>    if (ctx->record_type)
>      {
> -      tree clobber = build_constructor (TREE_TYPE (ctx->sender_decl), NULL);
> -      TREE_THIS_VOLATILE (clobber) = 1;
> +      tree clobber = build_clobber (TREE_TYPE (ctx->sender_decl));
>        gimple_seq_add_stmt (&olist, gimple_build_assign (ctx->sender_decl,
>  							clobber));
>      }
> @@ -11911,16 +11906,13 @@ lower_omp_target (gimple_stmt_iterator *
>  				  &initlist, true, NULL_TREE);
>  	    gimple_seq_add_seq (&ilist, initlist);
>  
> -	    tree clobber = build_constructor (TREE_TYPE (TREE_VEC_ELT (t, i)),
> -					      NULL);
> -	    TREE_THIS_VOLATILE (clobber) = 1;
> +	    tree clobber = build_clobber (TREE_TYPE (TREE_VEC_ELT (t, i)));
>  	    gimple_seq_add_stmt (&olist,
>  				 gimple_build_assign (TREE_VEC_ELT (t, i),
>  						      clobber));
>  	  }
>  
> -      tree clobber = build_constructor (ctx->record_type, NULL);
> -      TREE_THIS_VOLATILE (clobber) = 1;
> +      tree clobber = build_clobber (ctx->record_type);
>        gimple_seq_add_stmt (&olist, gimple_build_assign (ctx->sender_decl,
>  							clobber));
>      }
> --- gcc/omp-expand.c.jj	2019-07-17 09:13:33.116700818 +0200
> +++ gcc/omp-expand.c	2019-09-25 18:25:20.272751297 +0200
> @@ -2988,8 +2988,7 @@ expand_omp_for_generic (struct omp_regio
>  				true, GSI_SAME_STMT);
>    if (arr && !TREE_STATIC (arr))
>      {
> -      tree clobber = build_constructor (TREE_TYPE (arr), NULL);
> -      TREE_THIS_VOLATILE (clobber) = 1;
> +      tree clobber = build_clobber (TREE_TYPE (arr));
>        gsi_insert_before (&gsi, gimple_build_assign (arr, clobber),
>  			 GSI_SAME_STMT);
>      }
> @@ -3356,8 +3355,7 @@ expand_omp_for_generic (struct omp_regio
>    if (fd->ordered)
>      {
>        tree arr = counts[fd->ordered];
> -      tree clobber = build_constructor (TREE_TYPE (arr), NULL);
> -      TREE_THIS_VOLATILE (clobber) = 1;
> +      tree clobber = build_clobber (TREE_TYPE (arr));
>        gsi_insert_after (&gsi, gimple_build_assign (arr, clobber),
>  			GSI_SAME_STMT);
>      }
> --- gcc/omp-offload.c.jj	2019-08-10 10:45:22.655044642 +0200
> +++ gcc/omp-offload.c	2019-09-25 18:26:39.984540650 +0200
> @@ -1855,8 +1855,7 @@ ompdevlow_adjust_simt_enter (gimple_stmt
>      {
>        gcc_assert (gimple_call_internal_p (exit_stmt, IFN_GOMP_SIMT_EXIT));
>        gimple_stmt_iterator exit_gsi = gsi_for_stmt (exit_stmt);
> -      tree clobber = build_constructor (rectype, NULL);
> -      TREE_THIS_VOLATILE (clobber) = 1;
> +      tree clobber = build_clobber (rectype);
>        exit_stmt = gimple_build_assign (build_simple_mem_ref (simtrec), clobber);
>        gsi_insert_before (&exit_gsi, exit_stmt, GSI_SAME_STMT);
>      }
> 
> 	Jakub
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 247165 (AG München)

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