From patchwork Thu Nov 6 14:31:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 407561 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DA01A14007D for ; Fri, 7 Nov 2014 01:52:58 +1100 (AEDT) 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:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=S3O77TLhS5GvmV+HWtHhggwhY4xA2g/nVINEzIsQFKFW2NLHnm+qa HXzINp4t2dzMVB/x6innqKf7dNFN7vdO7MxHGcsxJ9vNygVIR0bo0VeEUDqeURFY pwpgme2kIRLYB0wb9ojOAOtCN3abX46HVTPzS7GjsfADnUAMc8f1LI= 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:cc:subject:date:message-id:in-reply-to:references; s= default; bh=yEwmWRs4nz2EZYnQX09T0dEcE8Q=; b=ZarEsItU3jTrMnGyFfw/ epUT4YXCyBgvzOYSFxwUTNt2PLhpNBjIRfxJM2Ny/cBc9rvACZnWTEn7+/AKNKs0 d5DDKG+XAiin2XKdqy7kq6vNvJXIiHLI1uv9Giei3+eQT960h/ncB+rEOhXPI7dO 4vf4l2+QAGq9NHg528FrDzI= Received: (qmail 11118 invoked by alias); 6 Nov 2014 14:52: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 11036 invoked by uid 89); 6 Nov 2014 14:52:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 06 Nov 2014 14:52:40 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XmOBG-0006op-L7 for gcc-patches@gcc.gnu.org; Thu, 06 Nov 2014 09:37:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51307) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XmOBG-0006oj-EA for gcc-patches@gcc.gnu.org; Thu, 06 Nov 2014 09:36:58 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sA6EaviK017855 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 6 Nov 2014 09:36:57 -0500 Received: from surprise.redhat.com (vpn-235-14.phx2.redhat.com [10.3.235.14]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sA6Eag81016497; Thu, 6 Nov 2014 09:36:57 -0500 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [gimple-classes, committed 23/44] tree-ssa-alias.c: Use gassign Date: Thu, 6 Nov 2014 09:31:59 -0500 Message-Id: <1415284340-14186-24-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1415284340-14186-1-git-send-email-dmalcolm@redhat.com> References: <1415284340-14186-1-git-send-email-dmalcolm@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 X-IsSubscribed: yes gcc/ChangeLog.gimple-classes: * tree-ssa-alias.c (stmt_may_clobber_global_p): Within case GIMPLE_ASSIGN, add a checked cast. (ao_ref_init_from_ptr_and_size): Both the gimple_assign_single_p and is_gimple_assign conditionals require a GIMPLE_ASSIGN, so begin with a dyn_cast and check for NULL, strengthening local "stmt" from gimple to gassign *. (ref_maybe_used_by_stmt_p): Replace is_gimple_assign with a dyn_cast, introducing local "assign_stmt" and using it in place of "stmt" for typesafety. (stmt_may_clobber_ref_p_1): Add a checked cast. --- gcc/ChangeLog.gimple-classes | 13 +++++++++++++ gcc/tree-ssa-alias.c | 34 ++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index 6b0d704..9233d8a 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,18 @@ 2014-11-03 David Malcolm + * tree-ssa-alias.c (stmt_may_clobber_global_p): Within + case GIMPLE_ASSIGN, add a checked cast. + (ao_ref_init_from_ptr_and_size): Both the gimple_assign_single_p + and is_gimple_assign conditionals require a GIMPLE_ASSIGN, so + begin with a dyn_cast and check for NULL, + strengthening local "stmt" from gimple to gassign *. + (ref_maybe_used_by_stmt_p): Replace is_gimple_assign with a + dyn_cast, introducing local "assign_stmt" and using it in place of + "stmt" for typesafety. + (stmt_may_clobber_ref_p_1): Add a checked cast. + +2014-11-03 David Malcolm + * tree-nested.c (convert_local_reference_stmt): Add a checked cast within case GIMPLE_ASSIGN. diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 9b55e0d..f9bf939 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -387,7 +387,7 @@ stmt_may_clobber_global_p (gimple stmt) switch (gimple_code (stmt)) { case GIMPLE_ASSIGN: - lhs = gimple_assign_lhs (stmt); + lhs = gimple_assign_lhs (as_a (stmt)); return (TREE_CODE (lhs) != SSA_NAME && ref_may_alias_global_p (lhs)); case GIMPLE_CALL: @@ -605,17 +605,19 @@ ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size) ref->ref = NULL_TREE; if (TREE_CODE (ptr) == SSA_NAME) { - gimple stmt = SSA_NAME_DEF_STMT (ptr); - if (gimple_assign_single_p (stmt) - && gimple_assign_rhs_code (stmt) == ADDR_EXPR) - ptr = gimple_assign_rhs1 (stmt); - else if (is_gimple_assign (stmt) - && gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR - && TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST) + gassign *stmt = dyn_cast (SSA_NAME_DEF_STMT (ptr)); + if (stmt) { - ptr = gimple_assign_rhs1 (stmt); - extra_offset = BITS_PER_UNIT - * int_cst_value (gimple_assign_rhs2 (stmt)); + if (gimple_assign_single_p (stmt) + && gimple_assign_rhs_code (stmt) == ADDR_EXPR) + ptr = gimple_assign_rhs1 (stmt); + else if (gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR + && TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST) + { + ptr = gimple_assign_rhs1 (stmt); + extra_offset = (BITS_PER_UNIT + * int_cst_value (gimple_assign_rhs2 (stmt))); + } } } @@ -1816,18 +1818,18 @@ ref_maybe_used_by_call_p (gcall *call, ao_ref *ref) bool ref_maybe_used_by_stmt_p (gimple stmt, ao_ref *ref) { - if (is_gimple_assign (stmt)) + if (gassign *assign_stmt = dyn_cast (stmt)) { tree rhs; /* All memory assign statements are single. */ - if (!gimple_assign_single_p (stmt)) + if (!gimple_assign_single_p (assign_stmt)) return false; - rhs = gimple_assign_rhs1 (stmt); + rhs = gimple_assign_rhs1 (assign_stmt); if (is_gimple_reg (rhs) || is_gimple_min_invariant (rhs) - || gimple_assign_rhs_code (stmt) == CONSTRUCTOR) + || gimple_assign_rhs_code (assign_stmt) == CONSTRUCTOR) return false; return refs_may_alias_p (rhs, ref); @@ -2178,7 +2180,7 @@ stmt_may_clobber_ref_p_1 (gimple stmt, ao_ref *ref) } else if (gimple_assign_single_p (stmt)) { - tree lhs = gimple_assign_lhs (stmt); + tree lhs = gimple_assign_lhs (as_a (stmt)); if (TREE_CODE (lhs) != SSA_NAME) { ao_ref r;