From patchwork Mon Oct 27 20:41:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 403951 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 ECC6714007F for ; Tue, 28 Oct 2014 07:58:14 +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=p6PWSA3wZCkgwWiAcCWq6Cn/5lH4Hd2Ry62mUtgjn4ugiMlXUVC83 PLSGbNVVFnlrZNrTN41rU64jwccBjZIgvrJk/dCEBeIGfIKLPbRyeO+wLgb49js/ 6bA307rBQkjk4b1fKp20BNpSGM1RV1JpF1jwGTJCEQ42nPYCcngVpU= 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=MCs1DPM2TRwmJxLGm2oR+kRS80A=; b=OO0sdyoYhbPsJsdP8DA/ dM1rHU+I1SZBeMVJ8jTj9W0GjiSLWWb7Ef+YPP6NmOdNs1e6N2QMcy1c+3Zj1wM+ bsjeUbWjMMNpMlQgVCYuLISv6uPZJRu9EELQmFfpn+5PrrDUhFbmUUdwAGbecznU /zhwrVJiVmQsq0IID6onWFY= Received: (qmail 23279 invoked by alias); 27 Oct 2014 20:54:39 -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 23206 invoked by uid 89); 27 Oct 2014 20:54:38 -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; Mon, 27 Oct 2014 20:54:36 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xir1w-00089r-4d for gcc-patches@gcc.gnu.org; Mon, 27 Oct 2014 16:36:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xir1v-00089V-Tj for gcc-patches@gcc.gnu.org; Mon, 27 Oct 2014 16:36:44 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9RKZhLf018006 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 27 Oct 2014 16:35:43 -0400 Received: from c64.redhat.com (vpn-236-51.phx2.redhat.com [10.3.236.51]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9RKYt65021050; Mon, 27 Oct 2014 16:35:42 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [gimple-classes, committed 81/92] Concretize gimple_call_set_tail and gimple_call_tail_p Date: Mon, 27 Oct 2014 16:41:19 -0400 Message-Id: <1414442490-14841-82-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1414442490-14841-1-git-send-email-dmalcolm@redhat.com> References: <1414442490-14841-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 This corresponds to: [PATCH 83/89] Concretize gimple_call_set_tail and gimple_call_tail_p https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01172.html from the original 89-patch kit That earlier patch was approved by Jeff: > OK once prereqs go in. in https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00859.html gcc/ * gimple.h (gimple_call_set_tail): Require a gimple_call. (gimple_call_tail_p): Likewise. * cfgexpand.c (expand_gimple_tailcall): Likewise. (expand_gimple_basic_block): Convert calls to is_gimple_call to a dyn_cast, introducing a new "call_stmt" local. * trans-mem.c (expand_block_edges): Likewise, for comparison against GIMPLE_CALL. * tree-inline.c (remap_gimple_stmt): Add checked casts to gimple_call in region guarded by is_gimple_call. * tree-tailcall.c (optimize_tail_call): Add checked cast to gimple_call for t->call_gsi. --- gcc/ChangeLog.gimple-classes | 20 ++++++++++++++++++++ gcc/cfgexpand.c | 13 +++++++------ gcc/gimple.h | 6 ++---- gcc/trans-mem.c | 20 ++++++++++++-------- gcc/tree-inline.c | 4 ++-- gcc/tree-tailcall.c | 2 +- 6 files changed, 44 insertions(+), 21 deletions(-) diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes index f0737b9..56fe40d 100644 --- a/gcc/ChangeLog.gimple-classes +++ b/gcc/ChangeLog.gimple-classes @@ -1,5 +1,25 @@ 2014-10-24 David Malcolm + Concretize gimple_call_set_tail and gimple_call_tail_p + + * gimple.h (gimple_call_set_tail): Require a gimple_call. + (gimple_call_tail_p): Likewise. + + * cfgexpand.c (expand_gimple_tailcall): Likewise. + (expand_gimple_basic_block): Convert calls to is_gimple_call to a + dyn_cast, introducing a new "call_stmt" local. + + * trans-mem.c (expand_block_edges): Likewise, for comparison against + GIMPLE_CALL. + + * tree-inline.c (remap_gimple_stmt): Add checked casts to + gimple_call in region guarded by is_gimple_call. + + * tree-tailcall.c (optimize_tail_call): Add checked cast to gimple_call + for t->call_gsi. + +2014-10-24 David Malcolm + Concretize gimple_call_set_fntype * gimple-fold.c (gimple_fold_builtin_sprintf_chk): Strengthen diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 0715b83..65de5b2 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -3407,7 +3407,7 @@ expand_gimple_stmt (gimple stmt) tailcall) and the normal result happens via a sqrt instruction. */ static basic_block -expand_gimple_tailcall (basic_block bb, gimple stmt, bool *can_fallthru) +expand_gimple_tailcall (basic_block bb, gimple_call stmt, bool *can_fallthru) { rtx_insn *last2, *last; edge e; @@ -5172,15 +5172,16 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls) } else { - if (is_gimple_call (stmt) - && gimple_call_tail_p (stmt) + gimple_call call_stmt = dyn_cast (stmt); + if (call_stmt + && gimple_call_tail_p (call_stmt) && disable_tail_calls) - gimple_call_set_tail (stmt, false); + gimple_call_set_tail (call_stmt, false); - if (is_gimple_call (stmt) && gimple_call_tail_p (stmt)) + if (call_stmt && gimple_call_tail_p (call_stmt)) { bool can_fallthru; - new_bb = expand_gimple_tailcall (bb, stmt, &can_fallthru); + new_bb = expand_gimple_tailcall (bb, call_stmt, &can_fallthru); if (new_bb) { if (can_fallthru) diff --git a/gcc/gimple.h b/gcc/gimple.h index d37c441..9d09804 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -2808,9 +2808,8 @@ gimple_call_set_arg (gimple gs, unsigned index, tree arg) candidate for tail call optimization. */ static inline void -gimple_call_set_tail (gimple s, bool tail_p) +gimple_call_set_tail (gimple_call s, bool tail_p) { - GIMPLE_CHECK (s, GIMPLE_CALL); if (tail_p) s->subcode |= GF_CALL_TAILCALL; else @@ -2821,9 +2820,8 @@ gimple_call_set_tail (gimple s, bool tail_p) /* Return true if GIMPLE_CALL S is marked as a tail call. */ static inline bool -gimple_call_tail_p (gimple s) +gimple_call_tail_p (gimple_call s) { - GIMPLE_CHECK (s, GIMPLE_CALL); return (s->subcode & GF_CALL_TAILCALL) != 0; } diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index bdd4a77..0912cc8 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -3111,23 +3111,26 @@ expand_block_edges (struct tm_region *const region, basic_block bb) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi = next_gsi) { gimple stmt = gsi_stmt (gsi); + gimple_call call_stmt; next_gsi = gsi; gsi_next (&next_gsi); // ??? Shouldn't we split for any non-pure, non-irrevocable function? - if (gimple_code (stmt) != GIMPLE_CALL - || (gimple_call_flags (stmt) & ECF_TM_BUILTIN) == 0) + call_stmt = dyn_cast (stmt); + if ((!call_stmt) + || (gimple_call_flags (call_stmt) & ECF_TM_BUILTIN) == 0) continue; - if (DECL_FUNCTION_CODE (gimple_call_fndecl (stmt)) == BUILT_IN_TM_ABORT) + if (DECL_FUNCTION_CODE (gimple_call_fndecl (call_stmt)) + == BUILT_IN_TM_ABORT) { // If we have a ``_transaction_cancel [[outer]]'', there is only // one abnormal edge: to the transaction marked OUTER. // All compiler-generated instances of BUILT_IN_TM_ABORT have a // constant argument, which we can examine here. Users invoking // TM_ABORT directly get what they deserve. - tree arg = gimple_call_arg (stmt, 0); + tree arg = gimple_call_arg (call_stmt, 0); if (TREE_CODE (arg) == INTEGER_CST && (TREE_INT_CST_LOW (arg) & AR_OUTERABORT) != 0 && !decl_is_tm_clone (current_function_decl)) @@ -3136,7 +3139,7 @@ expand_block_edges (struct tm_region *const region, basic_block bb) for (struct tm_region *o = region; o; o = o->outer) if (o->original_transaction_was_outer) { - split_bb_make_tm_edge (stmt, o->restart_block, + split_bb_make_tm_edge (call_stmt, o->restart_block, gsi, &next_gsi); break; } @@ -3149,7 +3152,8 @@ expand_block_edges (struct tm_region *const region, basic_block bb) // Non-outer, TM aborts have an abnormal edge to the inner-most // transaction, the one being aborted; - split_bb_make_tm_edge (stmt, region->restart_block, gsi, &next_gsi); + split_bb_make_tm_edge (call_stmt, region->restart_block, gsi, + &next_gsi); } // All TM builtins have an abnormal edge to the outer-most transaction. @@ -3167,14 +3171,14 @@ expand_block_edges (struct tm_region *const region, basic_block bb) for (struct tm_region *o = region; o; o = o->outer) if (!o->outer) { - split_bb_make_tm_edge (stmt, o->restart_block, gsi, &next_gsi); + split_bb_make_tm_edge (call_stmt, o->restart_block, gsi, &next_gsi); break; } // Delete any tail-call annotation that may have been added. // The tail-call pass may have mis-identified the commit as being // a candidate because we had not yet added this restart edge. - gimple_call_set_tail (stmt, false); + gimple_call_set_tail (call_stmt, false); } } diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 11446d7..84dfea8 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -1549,8 +1549,8 @@ remap_gimple_stmt (gimple stmt, copy_body_data *id) /* Clear flags that need revisiting. */ if (is_gimple_call (copy) - && gimple_call_tail_p (copy)) - gimple_call_set_tail (copy, false); + && gimple_call_tail_p (as_a (copy))) + gimple_call_set_tail (as_a (copy), false); /* Remap the region numbers for __builtin_eh_{pointer,filter}, RESX and EH_DISPATCH. */ diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c index 9bf3c42..b941396 100644 --- a/gcc/tree-tailcall.c +++ b/gcc/tree-tailcall.c @@ -920,7 +920,7 @@ optimize_tail_call (struct tailcall *t, bool opt_tailcalls) if (opt_tailcalls) { - gimple stmt = gsi_stmt (t->call_gsi); + gimple_call stmt = as_a (gsi_stmt (t->call_gsi)); gimple_call_set_tail (stmt, true); cfun->tail_call_marked = true;