From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21796 invoked by alias); 19 Dec 2012 11:40:07 -0000 Received: (qmail 21787 invoked by uid 22791); 19 Dec 2012 11:40:06 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,TW_JF,T_RP_MATCHES_RCVD 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; Wed, 19 Dec 2012 11:40:02 +0000 Received: from relay2.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 A38A4A4F01 for ; Wed, 19 Dec 2012 12:40:00 +0100 (CET) Date: Wed, 19 Dec 2012 11:40:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR55736 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: 2012-12/txt/msg01176.txt.bz2 Switch conversion currently makes no effort to hide BLOCKs from locations of expressions it puts into the static constructors built. This causes issues at least for LTO where dead references to BLOCKs end up being produced for the varpool global initializers. But I can very well imagine that later CCP can re-expose these BLOCKs after they have been collected in a regular compilation as well. The patch moves the function that strips expressions of their location from ipa-prop.c next to unshare_expr and calls it unshare_expr_without_location. LTO bootstrap and regtest ongoing on x86_64-unknown-linux-gnu. Richard. 2012-12-19 Richard Biener PR tree-optimization/55736 * gimplify.c (prune_expr_location): New function. (unshare_expr_without_location): Likewise. * tree.h (unshare_expr_without_location): Declare. * ipa-prop.c (prune_expression_for_jf): Remove. (prune_expression_for_jf_1): Likewise. (ipa_set_jf_constant): Use unshare_expr_without_location. (ipa_set_jf_arith_pass_through): Likewise. (determine_known_aggregate_parts): Likewise. * tree-switch-conversion.c (build_constructors): Use unshare_expr_without_location on all constructor elements. Index: gcc/gimplify.c =================================================================== *** gcc/gimplify.c (revision 194578) --- gcc/gimplify.c (working copy) *************** unshare_expr (tree expr) *** 1059,1064 **** --- 1059,1088 ---- walk_tree (&expr, mostly_copy_tree_r, NULL, NULL); return expr; } + + /* Worker for unshare_expr_without_location. */ + + static tree + prune_expr_location (tree *tp, int *walk_subtrees, void *) + { + if (EXPR_P (*tp)) + SET_EXPR_LOCATION (*tp, UNKNOWN_LOCATION); + else + *walk_subtrees = 0; + return NULL_TREE; + } + + /* Similar to unshare_expr but also prune all expression locations + from EXPR. */ + + tree + unshare_expr_without_location (tree expr) + { + walk_tree (&expr, mostly_copy_tree_r, NULL, NULL); + if (EXPR_P (expr)) + walk_tree (&expr, prune_expr_location, NULL, NULL); + return expr; + } /* WRAPPER is a code such as BIND_EXPR or CLEANUP_POINT_EXPR which can both contain statements and have a value. Assign its value to a temporary Index: gcc/tree.h =================================================================== *** gcc/tree.h (revision 194578) --- gcc/tree.h (working copy) *************** extern void change_decl_assembler_name ( *** 5606,5611 **** --- 5606,5612 ---- /* In gimplify.c */ extern tree unshare_expr (tree); + extern tree unshare_expr_without_location (tree); /* In stmt.c */ Index: gcc/ipa-prop.c =================================================================== *** gcc/ipa-prop.c (revision 194578) --- gcc/ipa-prop.c (working copy) *************** ipa_print_all_jump_functions (FILE *f) *** 295,325 **** } } - /* Worker for prune_expression_for_jf. */ - - static tree - prune_expression_for_jf_1 (tree *tp, int *walk_subtrees, void *) - { - if (EXPR_P (*tp)) - SET_EXPR_LOCATION (*tp, UNKNOWN_LOCATION); - else - *walk_subtrees = 0; - return NULL_TREE; - } - - /* Return the expression tree EXPR unshared and with location stripped off. */ - - static tree - prune_expression_for_jf (tree exp) - { - if (EXPR_P (exp)) - { - exp = unshare_expr (exp); - walk_tree (&exp, prune_expression_for_jf_1, NULL, NULL); - } - return exp; - } - /* Set JFUNC to be a known type jump function. */ static void --- 295,300 ---- *************** ipa_set_jf_constant (struct ipa_jump_fun *** 341,347 **** if (constant && EXPR_P (constant)) SET_EXPR_LOCATION (constant, UNKNOWN_LOCATION); jfunc->type = IPA_JF_CONST; ! jfunc->value.constant = prune_expression_for_jf (constant); } /* Set JFUNC to be a simple pass-through jump function. */ --- 316,322 ---- if (constant && EXPR_P (constant)) SET_EXPR_LOCATION (constant, UNKNOWN_LOCATION); jfunc->type = IPA_JF_CONST; ! jfunc->value.constant = unshare_expr_without_location (constant); } /* Set JFUNC to be a simple pass-through jump function. */ *************** ipa_set_jf_arith_pass_through (struct ip *** 363,369 **** tree operand, enum tree_code operation) { jfunc->type = IPA_JF_PASS_THROUGH; ! jfunc->value.pass_through.operand = prune_expression_for_jf (operand); jfunc->value.pass_through.formal_id = formal_id; jfunc->value.pass_through.operation = operation; jfunc->value.pass_through.agg_preserved = false; --- 338,344 ---- tree operand, enum tree_code operation) { jfunc->type = IPA_JF_PASS_THROUGH; ! jfunc->value.pass_through.operand = unshare_expr_without_location (operand); jfunc->value.pass_through.formal_id = formal_id; jfunc->value.pass_through.operation = operation; jfunc->value.pass_through.agg_preserved = false; *************** determine_known_aggregate_parts (gimple *** 1385,1391 **** { struct ipa_agg_jf_item item; item.offset = list->offset - arg_offset; ! item.value = prune_expression_for_jf (list->constant); jfunc->agg.items->quick_push (item); } list = list->next; --- 1360,1366 ---- { struct ipa_agg_jf_item item; item.offset = list->offset - arg_offset; ! item.value = unshare_expr_without_location (list->constant); jfunc->agg.items->quick_push (item); } list = list->next; Index: gcc/tree-switch-conversion.c =================================================================== *** gcc/tree-switch-conversion.c (revision 194578) --- gcc/tree-switch-conversion.c (working copy) *************** build_constructors (gimple swtch, struct *** 873,879 **** constructor_elt elt; elt.index = int_const_binop (MINUS_EXPR, pos, info->range_min); ! elt.value = info->default_values[k]; info->constructors[k]->quick_push (elt); } --- 873,880 ---- constructor_elt elt; elt.index = int_const_binop (MINUS_EXPR, pos, info->range_min); ! elt.value ! = unshare_expr_without_location (info->default_values[k]); info->constructors[k]->quick_push (elt); } *************** build_constructors (gimple swtch, struct *** 899,905 **** constructor_elt elt; elt.index = int_const_binop (MINUS_EXPR, pos, info->range_min); ! elt.value = val; info->constructors[j]->quick_push (elt); pos = int_const_binop (PLUS_EXPR, pos, integer_one_node); --- 900,906 ---- constructor_elt elt; elt.index = int_const_binop (MINUS_EXPR, pos, info->range_min); ! elt.value = unshare_expr_without_location (val); info->constructors[j]->quick_push (elt); pos = int_const_binop (PLUS_EXPR, pos, integer_one_node);