From patchwork Mon Feb 23 10:09:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 442395 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 54165140111 for ; Mon, 23 Feb 2015 21:20:20 +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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=E0ZzbOigGyEgmm1nq rVh0VCaOaa3zK36TxrgbKZPdj6pMGqCFmXyk8FnocNy+G8jtPPHiBIV9xEbgVE9r nGyl/NBvwVxenoU+glABbkIAXa+jTUKF3JrDD1azoVQRb7Rkn4IuMPuGho8RJbkm JfaEd87Y7yQt42WLxbhSMQeQ7k= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=1omvm/7sA+yDjH26laJGldA 8ESs=; b=UC6Q1KRAhxKWgkSOl6Dkx3e1QBPcKKUVTaP93r5wnN57JybgWXuAOwS XF+dyMAIry+EKBeer1NRHY4pBQHslBznH+XCoXFHbAiOhFIyx5NRTHke/K85Js2G CchPFi3QLpqlLHNpx51pQvlP8GAvKStMvTNigdAQuiG9la3mTo0s= Received: (qmail 17525 invoked by alias); 23 Feb 2015 10:19:00 -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 6672 invoked by uid 89); 23 Feb 2015 10:18:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Feb 2015 10:17:12 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-03.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YPpxI-0003rr-1V from Tom_deVries@mentor.com ; Mon, 23 Feb 2015 02:09:36 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-03.mgc.mentorg.com (137.202.0.108) with Microsoft SMTP Server id 14.3.224.2; Mon, 23 Feb 2015 10:09:34 +0000 Message-ID: <54EAFC5B.1030003@mentor.com> Date: Mon, 23 Feb 2015 11:09:31 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Michael Matz CC: Richard Biener , Jakub Jelinek , GCC Patches Subject: Re: [PATCH][5/5] Postpone expanding va_arg until pass_stdarg References: <54E5BB06.2080102@mentor.com> <54E5D0D2.8080306@mentor.com> <54E9D5E2.3070805@mentor.com> In-Reply-To: On 23-02-15 09:26, Michael Matz wrote: > Hi, > > On Sun, 22 Feb 2015, Tom de Vries wrote: > >> Btw, I'm wondering if as run-time optimization we can tentatively set >> PROP_gimple_lva at the start of the gimple pass, and unset it in >> gimplify_va_arg_expr. That way we would avoid the loop in >> expand_ifn_va_arg_1 (over all bbs and gimples) in functions without >> va_arg. > > That makes sense. > I'll put this follow-up patch through testing. Thanks, - Tom 2015-02-23 Tom de Vries * gimplify.c (gimplify_function_tree): Tentatively set PROP_gimple_lva in cfun->curr_properties. (gimplify_va_arg_expr): Clear PROP_gimple_lva in cfun->curr_properties if we generate an IFN_VA_ARG. * tree-inline.c (expand_call_inline): Reset PROP_gimple_lva in dest function if PROP_gimple_lva is not set in src function. --- gcc/gimplify.c | 10 +++++++++- gcc/tree-inline.c | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 8ac6a35..497e2fa 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -9218,6 +9218,10 @@ gimplify_function_tree (tree fndecl) else push_struct_function (fndecl); + /* Tentatively set PROP_gimple_lva here, and reset it in gimplify_va_arg_expr + if necessary. */ + cfun->curr_properties |= PROP_gimple_lva; + for (parm = DECL_ARGUMENTS (fndecl); parm ; parm = DECL_CHAIN (parm)) { /* Preliminarily mark non-addressed complex variables as eligible @@ -9312,7 +9316,7 @@ gimplify_function_tree (tree fndecl) } DECL_SAVED_TREE (fndecl) = NULL_TREE; - cfun->curr_properties = PROP_gimple_any; + cfun->curr_properties |= PROP_gimple_any; pop_cfun (); } @@ -9431,6 +9435,10 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, tag = build_int_cst (build_pointer_type (type), 0); *expr_p = build_call_expr_internal_loc (loc, IFN_VA_ARG, type, 2, ap, tag); + /* Clear the tentatively set PROP_gimple_lva, to indicate that IFN_VA_ARG + needs to be expanded. */ + cfun->curr_properties &= ~PROP_gimple_lva; + return GS_OK; } diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index d8abe03..7dfef4f 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -4524,6 +4524,14 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id) id->src_cfun = DECL_STRUCT_FUNCTION (fn); id->call_stmt = stmt; + /* If the the src function contains an IFN_VA_ARG, then so will the dst + function after inlining. */ + if ((id->src_cfun->curr_properties & PROP_gimple_lva) == 0) + { + struct function *dst_cfun = DECL_STRUCT_FUNCTION (id->dst_fn); + dst_cfun->curr_properties &= ~PROP_gimple_lva; + } + gcc_assert (!id->src_cfun->after_inlining); id->entry_bb = bb; -- 1.9.1