From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Do not allow sharing of handled_component_p's
Date: Mon, 14 Jan 2013 13:04:00 -0000 [thread overview]
Message-ID: <alpine.LNX.2.00.1301141402280.6889@zhemvz.fhfr.qr> (raw)
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 ----
reply other threads:[~2013-01-14 13:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.00.1301141402280.6889@zhemvz.fhfr.qr \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).