From patchwork Fri Sep 27 11:17:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 278546 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 77E7F2C008F for ; Fri, 27 Sep 2013 21:17:48 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=Dp6c/YssG197dwNc 4F4EXrooYKqiJV/yVmrAj/wJAlA0r6gEF0WZTJcCg2Pb4pM5OtVEfqu9qPVn5Qiy yO4wW5G3hAbZUeNfSCNKyNGgYT+Nrr0Zd6dvQM3tPxJtcHJbl1Z3UsRiSSgDHizf Wr3fEsua3FsrKJ9YjYZRVS6zBDk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=rYcJ5hNOs7oK46OXwRLpAu M6lBM=; b=cJpAwwQjQDzdBO1QARtbZsitJXJ2RCp52/6kl42NAm9TvDWQ9yLcL+ HgzRYfi5CgvhttYLjaIbMW9fAbZUYZD7cvbz3NRCvVyzsUJqfjJesVEvqjCz5AsM sOvemEgSFvmzwICr/ItyK1rmzS110PKBWQdfR5sGU5ZVhXUVCxN+I= Received: (qmail 32465 invoked by alias); 27 Sep 2013 11:17:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 32451 invoked by uid 89); 27 Sep 2013 11:17:40 -0000 Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 27 Sep 2013 11:17:40 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.4 required=5.0 tests=ALL_TRUSTED, AWL, BAYES_50, SPAM_SUBJECT autolearn=no version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 53FE2268316E for ; Fri, 27 Sep 2013 13:17:36 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TmYPbl80FTy8 for ; Fri, 27 Sep 2013 13:17:36 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 2721F2682E5D for ; Fri, 27 Sep 2013 13:17:36 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Fix PR bootstrap/58509 Date: Fri, 27 Sep 2013 13:17:08 +0200 Message-ID: <4797238.rpsq4UIoxF@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.29-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 Hi, this fixes the ICE during the build of the Ada runtime on the SPARC, a fallout of the recent inliner changes: http://gcc.gnu.org/ml/gcc-patches/2013-09/msg01033.html The ICE is triggered because the ldd peephole merges an MEM with MEM_NOTRAP_P and a contiguous MEM without MEM_NOTRAP_P, keeping the MEM_NOTRAP_P flag on the result. As a consequence, an EH edge is eliminated and a BB is orphaned. I think this shows that my above inliner patch was too gross: when you have successive inlining, you can quickly end up with a mess of trapping and non- trapping memory accesses for the same object. So the attached seriously refines it, restricting it to parameters with reference type and leaning towards being less conservative. Again, this should only affect Ada. Tested on x86_64-suse-linux, OK for the mainline? 2013-09-27 Eric Botcazou PR bootstrap/58509 * ipa-prop.h (get_ancestor_addr_info): Declare. * ipa-prop.c (get_ancestor_addr_info): Make public. * tree-inline.c (is_parm): Rename into... (is_ref_parm): ...this. (is_based_on_ref_parm): New predicate. (remap_gimple_op_r): Do not propagate TREE_THIS_NOTRAP on MEM_REF if a parameter with reference type has been remapped and the result is not based on another parameter with reference type. (copy_tree_body_r): Likewise on INDIRECT_REF and MEM_REF. 2013-09-27 Eric Botcazou * gnat.dg/specs/opt1.ads: New test. Index: tree-inline.c =================================================================== --- tree-inline.c (revision 202912) +++ tree-inline.c (working copy) @@ -751,10 +751,11 @@ copy_gimple_bind (gimple stmt, copy_body return new_bind; } -/* Return true if DECL is a parameter or a SSA_NAME for a parameter. */ +/* Return true if DECL is a parameter with reference type or a SSA_NAME + for a parameter with reference type. */ static bool -is_parm (tree decl) +is_ref_parm (tree decl) { if (TREE_CODE (decl) == SSA_NAME) { @@ -763,7 +764,40 @@ is_parm (tree decl) return false; } - return (TREE_CODE (decl) == PARM_DECL); + return (TREE_CODE (decl) == PARM_DECL + && TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE); +} + +/* Return true if DECL is based on a parameter with reference type or a + SSA_NAME for a parameter with with reference type. */ + +static bool +is_based_on_ref_parm (tree decl) +{ + HOST_WIDE_INT offset; + tree obj, expr; + gimple def_stmt; + + /* First the easy case. */ + if (is_ref_parm (decl)) + return true; + + /* Then look for an SSA name whose defining statement is of the form: + + D.1718_7 = &parm_2(D)->f1; + + where parm_2 is a parameter with reference type. */ + if (TREE_CODE (decl) != SSA_NAME) + return false; + def_stmt = SSA_NAME_DEF_STMT (decl); + if (!def_stmt) + return false; + + expr = get_ancestor_addr_info (def_stmt, &obj, &offset); + if (!expr) + return false; + + return is_ref_parm (TREE_OPERAND (expr, 0)); } /* Remap the GIMPLE operand pointed to by *TP. DATA is really a @@ -865,12 +899,13 @@ remap_gimple_op_r (tree *tp, int *walk_s TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old); TREE_SIDE_EFFECTS (*tp) = TREE_SIDE_EFFECTS (old); TREE_NO_WARNING (*tp) = TREE_NO_WARNING (old); - /* We cannot propagate the TREE_THIS_NOTRAP flag if we have - remapped a parameter as the property might be valid only - for the parameter itself. */ + /* We cannot always propagate the TREE_THIS_NOTRAP flag if we have + remapped a parameter with reference type as the property may be + valid only for the parameter. */ if (TREE_THIS_NOTRAP (old) - && (!is_parm (TREE_OPERAND (old, 0)) - || (!id->transform_parameter && is_parm (ptr)))) + && (!is_ref_parm (TREE_OPERAND (old, 0)) + || !id->transform_parameter + || is_based_on_ref_parm (ptr))) TREE_THIS_NOTRAP (*tp) = 1; *walk_subtrees = 0; return NULL; @@ -1092,12 +1127,13 @@ copy_tree_body_r (tree *tp, int *walk_su TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old); TREE_SIDE_EFFECTS (*tp) = TREE_SIDE_EFFECTS (old); TREE_READONLY (*tp) = TREE_READONLY (old); - /* We cannot propagate the TREE_THIS_NOTRAP flag if we - have remapped a parameter as the property might be - valid only for the parameter itself. */ + /* We cannot always propagate the TREE_THIS_NOTRAP flag + if we have remapped a parameter with reference type as + the property may be valid only for the parameter. */ if (TREE_THIS_NOTRAP (old) - && (!is_parm (TREE_OPERAND (old, 0)) - || (!id->transform_parameter && is_parm (ptr)))) + && (!is_ref_parm (TREE_OPERAND (old, 0)) + || !id->transform_parameter + || is_based_on_ref_parm (ptr))) TREE_THIS_NOTRAP (*tp) = 1; } } @@ -1118,12 +1154,13 @@ copy_tree_body_r (tree *tp, int *walk_su TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old); TREE_SIDE_EFFECTS (*tp) = TREE_SIDE_EFFECTS (old); TREE_NO_WARNING (*tp) = TREE_NO_WARNING (old); - /* We cannot propagate the TREE_THIS_NOTRAP flag if we have - remapped a parameter as the property might be valid only - for the parameter itself. */ + /* We cannot always propagate the TREE_THIS_NOTRAP flag if we have + remapped a parameter with reference type as the property may be + valid only for the parameter. */ if (TREE_THIS_NOTRAP (old) - && (!is_parm (TREE_OPERAND (old, 0)) - || (!id->transform_parameter && is_parm (ptr)))) + && (!is_ref_parm (TREE_OPERAND (old, 0)) + || !id->transform_parameter + || is_based_on_ref_parm (ptr))) TREE_THIS_NOTRAP (*tp) = 1; *walk_subtrees = 0; return NULL; Index: ipa-prop.h =================================================================== --- ipa-prop.h (revision 202912) +++ ipa-prop.h (working copy) @@ -693,6 +693,7 @@ tree ipa_value_from_jfunc (struct ipa_no unsigned int ipcp_transform_function (struct cgraph_node *node); void ipa_dump_param (FILE *, struct ipa_node_params *info, int i); +tree get_ancestor_addr_info (gimple, tree *, HOST_WIDE_INT *); /* From tree-sra.c: */ tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, tree, Index: ipa-prop.c =================================================================== --- ipa-prop.c (revision 202912) +++ ipa-prop.c (working copy) @@ -1078,7 +1078,7 @@ compute_complex_assign_jump_func (struct handled components and the MEM_REF itself is stored into *OFFSET. The whole RHS stripped off the ADDR_EXPR is stored into *OBJ_P. */ -static tree +tree get_ancestor_addr_info (gimple assign, tree *obj_p, HOST_WIDE_INT *offset) { HOST_WIDE_INT size, max_size;