From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5989 invoked by alias); 22 Jan 2015 10:23:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 5978 invoked by uid 89); 22 Jan 2015 10:23:32 -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 autolearn=ham version=3.3.2 X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 22 Jan 2015 10:23:29 +0000 Received: from pps.filterd (m0046670.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.14.5/8.14.5) with SMTP id t0MAAXSv000446; Thu, 22 Jan 2015 11:23:20 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 1s2tfnsdt0-1 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 22 Jan 2015 11:23:20 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 28E3B3C; Thu, 22 Jan 2015 10:22:29 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas6.st.com [10.75.90.73]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5C8F117EC; Thu, 22 Jan 2015 10:23:15 +0000 (GMT) Received: from [164.129.122.197] (164.129.122.197) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.3.342.0; Thu, 22 Jan 2015 11:23:14 +0100 Message-ID: <54C0CF92.6080001@st.com> Date: Thu, 22 Jan 2015 10:36:00 -0000 From: Christian Bruel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: ramana Radhakrishnan , Richard Biener Cc: Subject: Re: [PATCH] Fix inlining checks wrt optimize attribute References: In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.13.68,1.0.33,0.0.0000 definitions=2015-01-22_04:2015-01-22,2015-01-22,1970-01-01 signatures=0 X-IsSubscribed: yes X-SW-Source: 2015-01/txt/msg01987.txt.bz2 Hi Richard, I thought one of my current issue would be solved by this patch, but it is not : I have some inlining failures with the attribute target on ARM. (e.g inline-3.c) where obvious early inline fails with because we fail into the last can_inline_edge_p case: opt_for_fn (callee->decl, optimize) >= opt_for_fn (caller->decl, optimize))) when callee and caller are both -O2 and targetm.target_option.can_inline_p was true, they should be inlined as in the general case (no DECL_FUNCTION_SPECIFIC_OPTIMIZATION) I'm currently testing this additional change: Index: ipa-inline.c =================================================================== --- ipa-inline.c (revision 219989) +++ ipa-inline.c (working copy) @@ -489,7 +489,7 @@ else if (opt_for_fn (callee->decl, optimize_size) < opt_for_fn (caller->decl, optimize_size) || (opt_for_fn (callee->decl, optimize) - >= opt_for_fn (caller->decl, optimize))) + > opt_for_fn (caller->decl, optimize))) { if (estimate_edge_time (e) >= 20 + inline_edge_summary (e)->call_stmt_time) Since this is a hot topic for you, I though you would have useful comments on this before I ask for a commit (when stage 4 close) ? Cheers Christian On 01/22/2015 10:24 AM, Richard Biener wrote: > > As said in the other thread - this makes sure we don't perform inlining > that might end up generating invalid code. It also preserves > user-provided optimize attributes more properly. > > Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. > > Richard. > > 2015-01-22 Richard Biener > > * ipa-inline.c (can_inline_edge_p): Disable inlining of edges > with IL incompatible options. Properly honor user optimize > attributes. > > Index: gcc/ipa-inline.c > =================================================================== > --- gcc/ipa-inline.c (revision 219929) > +++ gcc/ipa-inline.c (working copy) > @@ -404,17 +404,56 @@ can_inline_edge_p (struct cgraph_edge *e > optimization attribute. */ > else if (caller_tree != callee_tree) > { > - /* gcc.dg/pr43564.c. Look at forced inline even in -O0. */ > - if (DECL_DISREGARD_INLINE_LIMITS (callee->decl)) > + /* There are some options that change IL semantics which means > + we cannot inline in these cases for correctness reason. > + Not even for always_inline declared functions. */ > + /* Strictly speaking only when the callee contains signed integer > + math where overflow is undefined. */ > + if ((opt_for_fn (e->caller->decl, flag_strict_overflow) > + != opt_for_fn (e->caller->decl, flag_strict_overflow)) > + || (opt_for_fn (e->caller->decl, flag_wrapv) > + != opt_for_fn (e->caller->decl, flag_wrapv)) > + || (opt_for_fn (e->caller->decl, flag_trapv) > + != opt_for_fn (e->caller->decl, flag_trapv)) > + /* Strictly speaking only when the callee contains memory > + accesses that are not using alias-set zero anyway. */ > + || (opt_for_fn (e->caller->decl, flag_strict_aliasing) > + != opt_for_fn (e->caller->decl, flag_strict_aliasing)) > + /* Strictly speaking only when the callee uses FP math. */ > + || (opt_for_fn (e->caller->decl, flag_rounding_math) > + != opt_for_fn (e->caller->decl, flag_rounding_math)) > + || (opt_for_fn (e->caller->decl, flag_trapping_math) > + != opt_for_fn (e->caller->decl, flag_trapping_math)) > + || (opt_for_fn (e->caller->decl, flag_unsafe_math_optimizations) > + != opt_for_fn (e->caller->decl, flag_unsafe_math_optimizations)) > + || (opt_for_fn (e->caller->decl, flag_finite_math_only) > + != opt_for_fn (e->caller->decl, flag_finite_math_only)) > + || (opt_for_fn (e->caller->decl, flag_signaling_nans) > + != opt_for_fn (e->caller->decl, flag_signaling_nans)) > + || (opt_for_fn (e->caller->decl, flag_cx_limited_range) > + != opt_for_fn (e->caller->decl, flag_cx_limited_range)) > + || (opt_for_fn (e->caller->decl, flag_signed_zeros) > + != opt_for_fn (e->caller->decl, flag_signed_zeros)) > + || (opt_for_fn (e->caller->decl, flag_associative_math) > + != opt_for_fn (e->caller->decl, flag_associative_math)) > + || (opt_for_fn (e->caller->decl, flag_reciprocal_math) > + != opt_for_fn (e->caller->decl, flag_reciprocal_math)) > + /* Strictly speaking only when the callee contains function > + calls that may end up setting errno. */ > + || (opt_for_fn (e->caller->decl, flag_errno_math) > + != opt_for_fn (e->caller->decl, flag_errno_math))) > + { > + e->inline_failed = CIF_OPTIMIZATION_MISMATCH; > + inlinable = false; > + } > + /* gcc.dg/pr43564.c. Apply user-forced inline even at -O0. */ > + else if (DECL_DISREGARD_INLINE_LIMITS (callee->decl) > + && lookup_attribute ("always_inline", > + DECL_ATTRIBUTES (callee->decl))) > ; > - /* When user added an attribute, honnor it. */ > - else if ((lookup_attribute ("optimize", DECL_ATTRIBUTES (caller->decl)) > - || lookup_attribute ("optimize", > - DECL_ATTRIBUTES (callee->decl))) > - && ((opt_for_fn (caller->decl, optimize) > - > opt_for_fn (callee->decl, optimize)) > - || (opt_for_fn (caller->decl, optimize_size) > - != opt_for_fn (callee->decl, optimize_size)))) > + /* When user added an attribute to the callee honor it. */ > + else if (lookup_attribute ("optimize", DECL_ATTRIBUTES (callee->decl)) > + && opts_for_fn (caller->decl) != opts_for_fn (callee->decl)) > { > e->inline_failed = CIF_OPTIMIZATION_MISMATCH; > inlinable = false; >