From patchwork Thu Nov 6 14:31:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 407531 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 5BEAD1400AB for ; Fri, 7 Nov 2014 01:39:16 +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=V34lBa9Tkp1l1TjyWFqMeAuc13gaidUiX6kKte0/CysHb/IMpaG25 6VTglFMDxNgzVRQYTAIDeugtr+TT18KixoVFmqj0CvsywMQlMhsFjVwsU5xCd49r 6+9FZbkRyVgeVVq4on8NoQOg53pcdb5gHny7hax1Z2djUluVEI4nDQ= 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=KIk54xyDD7ug15ra0SjVXPCkurg=; b=CDnbFOuVrAgc0etGgceh iJBv8MZlIvytHDxMW+QJLjMLESltaoVy0Ba344mJWXAsfRFXBdmKIN8te9jhkjNt PJh3NTw4ax9KaLuJKtbmxgpTf8q5U0F01g6OgOOrz+/kSJCzSEyRIIMbFLCLdjiG gGZ4bsos9lsVYV7rm9haWVs= Received: (qmail 24840 invoked by alias); 6 Nov 2014 14:36:59 -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 24606 invoked by uid 89); 6 Nov 2014 14:36:58 -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:36:56 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XmOB6-0006k3-Gu for gcc-patches@gcc.gnu.org; Thu, 06 Nov 2014 09:36:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XmOB6-0006jp-99 for gcc-patches@gcc.gnu.org; Thu, 06 Nov 2014 09:36:48 -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 sA6Eakje015079 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 6 Nov 2014 09:36:46 -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 sA6Eag7h016497; Thu, 6 Nov 2014 09:36:46 -0500 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [gimple-classes, committed 05/44] More gcall * Date: Thu, 6 Nov 2014 09:31:41 -0500 Message-Id: <1415284340-14186-6-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: * gimple.c (gimple_set_lhs): Add checked casts to gassign * and gcall * as appropriate. * tree-cfg.c (execute_fixup_cfg): Introduce local "call_stmt" via a dyn_cast and use it in place of "stmt" where appropriate * tree-cfgcleanup.c (split_bb_on_noreturn_calls): Strengthen local "stmt" from gimple to gcall *, replacing an is_gimple_call with a dyn_cast. * tree-cfgcleanup.h (fixup_noreturn_call): Strengthen param from gimple to gcall *. * tree-ssa-dce.c (eliminate_unnecessary_stmts): Replace is_gimple_call with a dyn_cast, introducing local "call_stmt" and using it in place of "stmt" for typesafety. * tree-ssa-propagate.c (finish_update_gimple_call): Strengthen params "new_stmt" and "stmt" from gimple to gcall *. --- gcc/ChangeLog.gimple-classes | 17 +++++++++++++++++ gcc/gimple.c | 4 ++-- gcc/tree-cfg.c | 9 +++++---- gcc/tree-cfgcleanup.c | 4 ++-- gcc/tree-cfgcleanup.h | 2 +- gcc/tree-ssa-dce.c | 10 +++++----- gcc/tree-ssa-propagate.c | 4 ++-- 7 files changed, 34 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index e2fb3d2..33bd5bf 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,22 @@ 2014-10-31 David Malcolm + * gimple.c (gimple_set_lhs): Add checked casts to gassign * and + gcall * as appropriate. + * tree-cfg.c (execute_fixup_cfg): Introduce local "call_stmt" + via a dyn_cast and use it in place of "stmt" where appropriate + * tree-cfgcleanup.c (split_bb_on_noreturn_calls): Strengthen + local "stmt" from gimple to gcall *, replacing an is_gimple_call + with a dyn_cast. + * tree-cfgcleanup.h (fixup_noreturn_call): Strengthen param from + gimple to gcall *. + * tree-ssa-dce.c (eliminate_unnecessary_stmts): Replace + is_gimple_call with a dyn_cast, introducing local "call_stmt" and + using it in place of "stmt" for typesafety. + * tree-ssa-propagate.c (finish_update_gimple_call): Strengthen + params "new_stmt" and "stmt" from gimple to gcall *. + +2014-10-31 David Malcolm + * config/i386/i386.c (add_condition_to_bb): Strengthen local "call_cond_stmt" from gimple to gcall *. * gimple-fold.c (gimple_build): Likewise for local "stmt". diff --git a/gcc/gimple.c b/gcc/gimple.c index b58c9db..d86ca49 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1640,9 +1640,9 @@ gimple_set_lhs (gimple stmt, tree lhs) enum gimple_code code = gimple_code (stmt); if (code == GIMPLE_ASSIGN) - gimple_assign_set_lhs (stmt, lhs); + gimple_assign_set_lhs (as_a (stmt), lhs); else if (code == GIMPLE_CALL) - gimple_call_set_lhs (stmt, lhs); + gimple_call_set_lhs (as_a (stmt), lhs); else gcc_unreachable (); } diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 1d1aaef..1ec250b 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -8555,12 +8555,13 @@ execute_fixup_cfg (void) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);) { gimple stmt = gsi_stmt (gsi); - tree decl = is_gimple_call (stmt) - ? gimple_call_fndecl (stmt) + gcall *call_stmt = dyn_cast (stmt); + tree decl = call_stmt + ? gimple_call_fndecl (call_stmt) : NULL; if (decl) { - int flags = gimple_call_flags (stmt); + int flags = gimple_call_flags (call_stmt); if (flags & (ECF_CONST | ECF_PURE | ECF_LOOPING_CONST_OR_PURE)) { if (gimple_purge_dead_abnormal_call_edges (bb)) @@ -8574,7 +8575,7 @@ execute_fixup_cfg (void) } if (flags & ECF_NORETURN - && fixup_noreturn_call (stmt)) + && fixup_noreturn_call (call_stmt)) todo |= TODO_cleanup_cfg; } diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c index 7383924..fc9f2af 100644 --- a/gcc/tree-cfgcleanup.c +++ b/gcc/tree-cfgcleanup.c @@ -645,9 +645,9 @@ split_bb_on_noreturn_calls (basic_block bb) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - gimple stmt = gsi_stmt (gsi); + gcall *stmt = dyn_cast (gsi_stmt (gsi)); - if (!is_gimple_call (stmt)) + if (!stmt) continue; if (gimple_call_noreturn_p (stmt)) diff --git a/gcc/tree-cfgcleanup.h b/gcc/tree-cfgcleanup.h index 19ff170..9538ddd 100644 --- a/gcc/tree-cfgcleanup.h +++ b/gcc/tree-cfgcleanup.h @@ -23,6 +23,6 @@ along with GCC; see the file COPYING3. If not see /* In tree-cfgcleanup.c */ extern bitmap cfgcleanup_altered_bbs; extern bool cleanup_tree_cfg (void); -extern bool fixup_noreturn_call (gimple stmt); +extern bool fixup_noreturn_call (gcall *stmt); #endif /* GCC_TREE_CFGCLEANUP_H */ diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index 06ffb24..20a4e40 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -1229,11 +1229,11 @@ eliminate_unnecessary_stmts (void) something_changed = true; remove_dead_stmt (&gsi, bb); } - else if (is_gimple_call (stmt)) + else if (gcall *call_stmt = dyn_cast (stmt)) { - tree name = gimple_call_lhs (stmt); + tree name = gimple_call_lhs (call_stmt); - notice_special_calls (as_a (stmt)); + notice_special_calls (call_stmt); /* When LHS of var = call (); is dead, simplify it into call (); saving one operand. */ @@ -1243,7 +1243,7 @@ eliminate_unnecessary_stmts (void) /* Avoid doing so for allocation calls which we did not mark as necessary, it will confuse the special logic we apply to malloc/free pair removal. */ - && (!(call = gimple_call_fndecl (stmt)) + && (!(call = gimple_call_fndecl (call_stmt)) || DECL_BUILT_IN_CLASS (call) != BUILT_IN_NORMAL || (DECL_FUNCTION_CODE (call) != BUILT_IN_ALIGNED_ALLOC && DECL_FUNCTION_CODE (call) != BUILT_IN_MALLOC @@ -1260,7 +1260,7 @@ eliminate_unnecessary_stmts (void) fprintf (dump_file, "\n"); } - gimple_call_set_lhs (stmt, NULL_TREE); + gimple_call_set_lhs (call_stmt, NULL_TREE); maybe_clean_or_replace_eh_stmt (stmt, stmt); update_stmt (stmt); release_ssa_name (name); diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index 6625000..478e8b9 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -727,8 +727,8 @@ move_ssa_defining_stmt_for_defs (gimple new_stmt, gimple old_stmt) A GIMPLE_CALL STMT is being replaced with GIMPLE_CALL NEW_STMT. */ static void -finish_update_gimple_call (gimple_stmt_iterator *si_p, gimple new_stmt, - gimple stmt) +finish_update_gimple_call (gimple_stmt_iterator *si_p, gcall *new_stmt, + gcall *stmt) { gimple_call_set_lhs (new_stmt, gimple_call_lhs (stmt)); move_ssa_defining_stmt_for_defs (new_stmt, stmt);