From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41177 invoked by alias); 15 Oct 2015 12:24:49 -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 41162 invoked by uid 89); 15 Oct 2015 12:24:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: gateway26.websitewelcome.com Received: from gateway26.websitewelcome.com (HELO gateway26.websitewelcome.com) (192.185.28.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 15 Oct 2015 12:24:46 +0000 Received: by gateway26.websitewelcome.com (Postfix, from userid 1000) id 5C97F5122E931; Thu, 15 Oct 2015 07:24:44 -0500 (CDT) Received: from gator3278.hostgator.com (gator3278.hostgator.com [198.57.247.242]) by gateway26.websitewelcome.com (Postfix) with ESMTP id 4B05A5122D290 for ; Thu, 15 Oct 2015 07:24:44 -0500 (CDT) Received: from [89.70.245.0] (port=33520 helo=localhost) by gator3278.hostgator.com with esmtpa (Exim 4.85) (envelope-from ) id 1ZmhaN-000GfU-91; Thu, 15 Oct 2015 07:24:43 -0500 Date: Thu, 15 Oct 2015 12:24:00 -0000 From: Arkadiusz Drabczyk To: Martin Sebor Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c/67925 - update documentation on `inline' Message-ID: <20151015122510.GA4459@comp.lan> References: <20151013224721.GA540@comp.lan> <561E687B.8000705@gmail.com> <20151014214245.GB20411@comp.lan> <561EF0BB.7090808@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <561EF0BB.7090808@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-BWhitelist: no X-Exim-ID: 1ZmhaN-000GfU-91 X-Source-Sender: (localhost) [89.70.245.0]:33520 X-Source-Auth: arkadiusz@drabczyk.org X-Email-Count: 1 X-Source-Cap: cmt1bXZicmg7cmt1bXZicmg7Z2F0b3IzMjc4Lmhvc3RnYXRvci5jb20= X-SW-Source: 2015-10/txt/msg01472.txt.bz2 On Wed, Oct 14, 2015 at 06:18:03PM -0600, Martin Sebor wrote: > On 10/14/2015 03:42 PM, Arkadiusz Drabczyk wrote: > >On Wed, Oct 14, 2015 at 08:36:43AM -0600, Martin Sebor wrote: > >>On 10/13/2015 04:47 PM, Arkadiusz Drabczyk wrote: > >>>* gcc/doc/extend.texi: documentation says that functions declared > >>>`inline' would not be integrated if they are called before they are > >>>defined or if they are recursive. Both of these statements is now > >>>false as shown in examples on Bugzilla. > >> > >>It might also be worth updating the note in the subsequent > >>paragraph and removing the mention of variable-length data types > >>which no longer prevent inlining. > > > >Done. I also removed the mention of nested functions as the following > >code compiled with GCC 6.0 doesn't give any warning with -O2 -Winline > >and main() is the only function defined in assembler code: > > I think this is the Ada-specific warning I mentioned (see > check_inlining_for_nested_subprog in gcc/ada/gcc-interface/trans.c) > so the part about nested functions needs to stay. Ok, I brought it back. > >> = G_("function %q+F can never be inlined because " > >> "it uses non-local goto"); > > > >I tested of all of these and listed them in the documentation but > >wasn't able to reproduce this one. The following code does not give > >any warning with -O2 -Winline: > > The warning above is issued for non-local and computed goto. You can > find examples of both in the test suite (find gcc/testsuite/ -name > "*goto*.[cC]") Aha, ok, I just thought that longjmp() counts as a non-local goto here. Indeed, this code invokes `function 'bar' can never be inlined because it uses non-local goto' with -O2 -Winline (but only if function that contains goto is nested, otherwise it fails to compile): #include #include int main (void) { __label__ l1; void foo (void) { inline void bar (void) { puts ("goto l1"); goto l1; } bar (); } foo (); abort (); l1: puts ("label l1"); return 0; } I brought back a mention of nonlocal goto and added a mention of __builtin_longjmp() as the usual longjmp() does not prevent inlining. >8------------------------------------------------------8< * gcc/doc/extend.texi: documentation says that functions declared `inline' would not be integrated if they are called before they are defined, if they are recursive, if they use variable-length data types or if they are nested. All of these statements are now false and have been removed. Mention of setjmp(), __builtin_longjmp(), __builtin_return() and __builtin_apply_args() has been added. --- gcc/doc/extend.texi | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 79440d3..bd559af 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -7088,21 +7088,19 @@ function are integrated into the caller, and the function's address is never used, then the function's own assembler code is never referenced. In this case, GCC does not actually output assembler code for the function, unless you specify the option @option{-fkeep-inline-functions}. -Some calls cannot be integrated for various reasons (in particular, -calls that precede the function's definition cannot be integrated, and -neither can recursive calls within the definition). If there is a -nonintegrated call, then the function is compiled to assembler code as -usual. The function must also be compiled as usual if the program -refers to its address, because that can't be inlined. +If there is a nonintegrated call, then the function is compiled to +assembler code as usual. The function must also be compiled as usual if +the program refers to its address, because that can't be inlined. @opindex Winline Note that certain usages in a function definition can make it unsuitable -for inline substitution. Among these usages are: variadic functions, use of -@code{alloca}, use of variable-length data types (@pxref{Variable Length}), -use of computed goto (@pxref{Labels as Values}), use of nonlocal goto, -and nested functions (@pxref{Nested Functions}). Using @option{-Winline} -warns when a function marked @code{inline} could not be substituted, -and gives the reason for the failure. +for inline substitution. Among these usages are: variadic functions, +use of @code{alloca}, use of computed goto (@pxref{Labels as Values}), +use of nonlocal goto, use of nested functions, use of @code{setjmp}, use +of @code{__builtin_longjmp} and use of @code{__builtin_return} or +@code{__builtin_apply_args}. Using @option{-Winline} warns when a +function marked @code{inline} could not be substituted, and gives the +reason for the failure. @cindex automatic @code{inline} for C++ member fns @cindex @code{inline} automatic for C++ member fns -- 2.3.5 -- Arkadiusz Drabczyk