This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][Middle-end][Version 2]Add a new option to control inlining only on static functions
- From: Qing Zhao <qing dot zhao at oracle dot com>
- To: Andrew Pinski <pinskia at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jeff Law <law at redhat dot com>, Richard Guenther <rguenther at suse dot de>, Jakub Jelinek <jakub at redhat dot com>, Alexander Monakov <amonakov at ispras dot ru>
- Date: Mon, 17 Sep 2018 09:25:37 -0500
- Subject: Re: [PATCH][Middle-end][Version 2]Add a new option to control inlining only on static functions
- References: <74719178-A2E7-4A65-BB0C-84DD4D3E6B08@oracle.com> <7E5FF9F1-EEBF-436F-B2C7-3A76617004AA@oracle.com> <CA+=Sn1khkzwSx-VV1EPXCfHWN-RL9YoSUkg2rs9cCH5MJNwYMQ@mail.gmail.com> <CA+=Sn1=zvTDgA_w0vBmWYHqqcJ8AbHaK=pTOAgALFo06_yhGsA@mail.gmail.com>
> On Sep 14, 2018, at 3:45 PM, Andrew Pinski <pinskia@gmail.com> wrote:
>
> On Fri, Sep 14, 2018 at 1:42 PM Andrew Pinski <pinskia@gmail.com <mailto:pinskia@gmail.com>> wrote:
>>
>> On Fri, Sep 14, 2018 at 1:34 PM Qing Zhao <qing.zhao@oracle.com> wrote:
>>>
>>> Hi,
>>>
>>> this is the 2nd version of the patch to add a new first-class option
>>>
>>> -finline-only-static
>>>
>>> to guide inlining only on static functions.
>>>
>>> -finline-only-static
>>> By default, GCC inlines functions without considering whether they are static
>>> or not. This flag guides inliner to only inline static functions.
>>>
>>> Off by default.
>>>
>>> The major purpose of this option is to provide a way for the user to disable inlining of global functions.
>>> this is mainly to help online patching users to control the memory consumption and ease the debugging.
>>>
>>> please take a look and let me know any comments and suggestions:
>>
>> How does this interact with -finline-functions? Or rather isn't this
>> just the opposite of -finline-functions?
>
> Seems to me, that this new option should just disable
> -finline-small-functions and -finline-functions.
> That is it is an alias with -fno-inline-small-functions -fno-inline-functions.
NO, this option is NOT to disable -finline-small-funcitons and -finline-functions.
when it’s specified, -finline-small-function and -finline-functions will ONLY inline static functions, all global functions will be disabled to
be inlined.
Qing
>
> My question comes up if someone uses -finline-functions
> -finline-only-static; or -finline-only-static -finline-functions.
> That it is a rather interesting combition of options but the
> interaction of the two options are not documented and seems backwards.
>
> Thanks,
> Andrew Pinski
>
>>
>> Thanks,
>> Andrew
>>
>>>
>>> thanks a lot.
>>>
>>> Qing
>>>
>>> gcc/ChangeLog
>>>
>>> +2018-09-13 Qing Zhao <qing.zhao@oracle.com>
>>> +
>>> + * cif-code.def (FUNCTION_EXTERN): New CIFCODE.
>>> + * common.opt (-finline-only-static): New option.
>>> + * doc/invoke.texi: Document -finline-only-static.
>>> + * ipa-inline.c (can_inline_edge_p): Control inlining based on
>>> + function's visibility.
>>>
>>> gcc/testsuite/ChangeLog
>>>
>>> +2018-09-13 Qing Zhao <qing.zhao@oracle.com>
>>> +
>>> + * gcc.dg/inline_only_static.c: New test.
>>> +
>>>
>>>
>>>
>>>> On Sep 11, 2018, at 10:12 AM, Qing Zhao <qing.zhao@oracle.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> This is a simple patch to add a new first-class option
>>>>
>>>> -finline-visibility={all|extern|static}
>>>>
>>>> to finer control inlining based on function’s visibility.
>>>>
>>>> '-finline-visibility=[all|extern|static]'
>>>> By default, GCC inlines functions without considering their
>>>> visibility. This flag allows finer control of inlining based on
>>>> their visibility.
>>>>
>>>> The value 'extern' tells the compiler to only inline functions with
>>>> external visibility. The value 'static' tells the compiler to only
>>>> inline functions with static visibility. The value 'all' tells the
>>>> compilers to inline functions without considering their visibility.
>>>>
>>>> The default value of '-finline-visibility' is 'all'.
>>>>
>>>> The major purpose of this option is to provide a way for the user
>>>> to finer choose the inline candidates based on function’s visibility.
>>>> For example, some online patching users might want to limit the inlining
>>>> to only static functions to avoid patching the callers of global functions
>>>> in order to control the memory consumption caused by online patching.
>>>>
>>>> let me know any comments and suggestions.
>>>>
>>>> thanks.
>>>>
>>>> Qing