From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17820 invoked by alias); 14 Jan 2013 13:04:34 -0000 Received: (qmail 17812 invoked by uid 22791); 14 Jan 2013 13:04:34 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,TW_TM X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Jan 2013 13:04:23 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id D813FA398F for ; Mon, 14 Jan 2013 14:04:21 +0100 (CET) Date: Mon, 14 Jan 2013 13:04:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Do not allow sharing of handled_component_p's Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00675.txt.bz2 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 * 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 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 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 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 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 ----