public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Do not allow sharing of handled_component_p's
@ 2013-01-14 13:04 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2013-01-14 13:04 UTC (permalink / raw)
  To: gcc-patches


For some reason they were allowed, which is definitely not a good
idea (they are unshared by all regular unsharing).  Direct fallout
is minor - it's the graphite changes which makes sure not to
share a[0].  The rest of the adjustments are for bugs sharing
ADDR_EXPRs (which is also bad as that has a location).

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2013-01-14  Richard Biener  <rguenther@suse.de>

	* tree-cfgcleanup.c (remove_forwarder_block): Unshare propagated
	PHI argument.
	* graphite-sese-to-poly.c (insert_out_of_ssa_copy): Properly
	unshare reference.
	(insert_out_of_ssa_copy_on_edge): Likewise.
	(rewrite_close_phi_out_of_ssa): Likewise.
	* tree-ssa.c (insert_debug_temp_for_var_def): Properly unshare
	debug expressions.
	* tree-ssa-pre.c (insert_into_preds_of_block): Properly unshare
	propagated constants.
	* tree-cfg.c (tree_node_can_be_shared): Handled component-refs
	can not be shared.

Index: gcc/tree-cfgcleanup.c
===================================================================
*** gcc/tree-cfgcleanup.c	(revision 195142)
--- gcc/tree-cfgcleanup.c	(working copy)
*************** remove_forwarder_block (basic_block bb)
*** 412,418 ****
  	    {
  	      gimple phi = gsi_stmt (gsi);
  	      source_location l = gimple_phi_arg_location_from_edge (phi, succ);
! 	      add_phi_arg (phi, gimple_phi_arg_def (phi, succ->dest_idx), s, l);
  	    }
  	}
      }
--- 412,419 ----
  	    {
  	      gimple phi = gsi_stmt (gsi);
  	      source_location l = gimple_phi_arg_location_from_edge (phi, succ);
! 	      tree def = gimple_phi_arg_def (phi, succ->dest_idx);
! 	      add_phi_arg (phi, unshare_expr (def), s, l);
  	    }
  	}
      }
Index: gcc/graphite-sese-to-poly.c
===================================================================
*** gcc/graphite-sese-to-poly.c	(revision 195142)
--- gcc/graphite-sese-to-poly.c	(working copy)
*************** insert_out_of_ssa_copy (scop_p scop, tre
*** 2020,2026 ****
    gimple_seq stmts;
    gimple_stmt_iterator gsi;
    tree var = force_gimple_operand (expr, &stmts, true, NULL_TREE);
!   gimple stmt = gimple_build_assign (res, var);
    vec<gimple> x;
    x.create (3);
  
--- 2020,2026 ----
    gimple_seq stmts;
    gimple_stmt_iterator gsi;
    tree var = force_gimple_operand (expr, &stmts, true, NULL_TREE);
!   gimple stmt = gimple_build_assign (unshare_expr (res), var);
    vec<gimple> x;
    x.create (3);
  
*************** insert_out_of_ssa_copy_on_edge (scop_p s
*** 2076,2082 ****
    gimple_stmt_iterator gsi;
    gimple_seq stmts = NULL;
    tree var = force_gimple_operand (expr, &stmts, true, NULL_TREE);
!   gimple stmt = gimple_build_assign (res, var);
    basic_block bb;
    vec<gimple> x;
    x.create (3);
--- 2076,2082 ----
    gimple_stmt_iterator gsi;
    gimple_seq stmts = NULL;
    tree var = force_gimple_operand (expr, &stmts, true, NULL_TREE);
!   gimple stmt = gimple_build_assign (unshare_expr (res), var);
    basic_block bb;
    vec<gimple> x;
    x.create (3);
*************** rewrite_close_phi_out_of_ssa (scop_p sco
*** 2232,2238 ****
      {
        tree zero_dim_array = create_zero_dim_array (res, "Close_Phi");
  
!       stmt = gimple_build_assign (res, zero_dim_array);
  
        if (TREE_CODE (arg) == SSA_NAME)
  	insert_out_of_ssa_copy (scop, zero_dim_array, arg,
--- 2232,2238 ----
      {
        tree zero_dim_array = create_zero_dim_array (res, "Close_Phi");
  
!       stmt = gimple_build_assign (res, unshare_expr (zero_dim_array));
  
        if (TREE_CODE (arg) == SSA_NAME)
  	insert_out_of_ssa_copy (scop, zero_dim_array, arg,
*************** rewrite_phi_out_of_ssa (scop_p scop, gim
*** 2258,2267 ****
    gimple phi = gsi_stmt (*psi);
    basic_block bb = gimple_bb (phi);
    tree res = gimple_phi_result (phi);
-   tree var;
    tree zero_dim_array = create_zero_dim_array (res, "phi_out_of_ssa");
    gimple stmt;
-   gimple_seq stmts;
  
    for (i = 0; i < gimple_phi_num_args (phi); i++)
      {
--- 2258,2265 ----
*************** rewrite_phi_out_of_ssa (scop_p scop, gim
*** 2278,2290 ****
  	insert_out_of_ssa_copy_on_edge (scop, e, zero_dim_array, arg);
      }
  
!   var = force_gimple_operand (zero_dim_array, &stmts, true, NULL_TREE);
! 
!   stmt = gimple_build_assign (res, var);
    remove_phi_node (psi, false);
    SSA_NAME_DEF_STMT (res) = stmt;
! 
!   insert_stmts (scop, stmt, stmts, gsi_after_labels (bb));
  }
  
  /* Rewrite the degenerate phi node at position PSI from the degenerate
--- 2276,2285 ----
  	insert_out_of_ssa_copy_on_edge (scop, e, zero_dim_array, arg);
      }
  
!   stmt = gimple_build_assign (res, unshare_expr (zero_dim_array));
    remove_phi_node (psi, false);
    SSA_NAME_DEF_STMT (res) = stmt;
!   insert_stmts (scop, stmt, NULL, gsi_after_labels (bb));
  }
  
  /* Rewrite the degenerate phi node at position PSI from the degenerate
Index: gcc/tree-ssa.c
===================================================================
*** gcc/tree-ssa.c	(revision 195142)
--- gcc/tree-ssa.c	(working copy)
*************** insert_debug_temp_for_var_def (gimple_st
*** 427,433 ****
  	      && (!gimple_assign_single_p (def_stmt)
  		  || is_gimple_min_invariant (value)))
  	  || is_gimple_reg (value))
! 	value = unshare_expr (value);
        else
  	{
  	  gimple def_temp;
--- 427,433 ----
  	      && (!gimple_assign_single_p (def_stmt)
  		  || is_gimple_min_invariant (value)))
  	  || is_gimple_reg (value))
! 	;
        else
  	{
  	  gimple def_temp;
*************** insert_debug_temp_for_var_def (gimple_st
*** 469,475 ****
  	       that was unshared when we found it had a single debug
  	       use, or a DEBUG_EXPR_DECL, that can be safely
  	       shared.  */
! 	    SET_USE (use_p, value);
  	  /* If we didn't replace uses with a debug decl fold the
  	     resulting expression.  Otherwise we end up with invalid IL.  */
  	  if (TREE_CODE (value) != DEBUG_EXPR_DECL)
--- 469,475 ----
  	       that was unshared when we found it had a single debug
  	       use, or a DEBUG_EXPR_DECL, that can be safely
  	       shared.  */
! 	    SET_USE (use_p, unshare_expr (value));
  	  /* If we didn't replace uses with a debug decl fold the
  	     resulting expression.  Otherwise we end up with invalid IL.  */
  	  if (TREE_CODE (value) != DEBUG_EXPR_DECL)
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c	(revision 195142)
--- gcc/tree-ssa-pre.c	(working copy)
*************** insert_into_preds_of_block (basic_block
*** 3246,3252 ****
        gcc_assert (get_expr_type (ae) == type
  		  || useless_type_conversion_p (type, get_expr_type (ae)));
        if (ae->kind == CONSTANT)
! 	add_phi_arg (phi, PRE_EXPR_CONSTANT (ae), pred, UNKNOWN_LOCATION);
        else
  	add_phi_arg (phi, PRE_EXPR_NAME (ae), pred, UNKNOWN_LOCATION);
      }
--- 3246,3253 ----
        gcc_assert (get_expr_type (ae) == type
  		  || useless_type_conversion_p (type, get_expr_type (ae)));
        if (ae->kind == CONSTANT)
! 	add_phi_arg (phi, unshare_expr (PRE_EXPR_CONSTANT (ae)),
! 		     pred, UNKNOWN_LOCATION);
        else
  	add_phi_arg (phi, PRE_EXPR_NAME (ae), pred, UNKNOWN_LOCATION);
      }
Index: gcc/tree-cfg.c
===================================================================
*** gcc/tree-cfg.c	(revision 195142)
--- gcc/tree-cfg.c	(working copy)
*************** tree_node_can_be_shared (tree t)
*** 4449,4461 ****
    if (TREE_CODE (t) == CASE_LABEL_EXPR)
      return true;
  
-   while (((TREE_CODE (t) == ARRAY_REF || TREE_CODE (t) == ARRAY_RANGE_REF)
- 	   && is_gimple_min_invariant (TREE_OPERAND (t, 1)))
- 	 || TREE_CODE (t) == COMPONENT_REF
- 	 || TREE_CODE (t) == REALPART_EXPR
- 	 || TREE_CODE (t) == IMAGPART_EXPR)
-     t = TREE_OPERAND (t, 0);
- 
    if (DECL_P (t))
      return true;
  
--- 4449,4454 ----

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-01-14 13:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-14 13:04 [PATCH] Do not allow sharing of handled_component_p's Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).