https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86141

--- Comment #11 from ASA <aaron_sami_abassi at hotmail dot com> ---
(In reply to Richard Biener from comment #7)
> When you rename main() to foo() the calls are inlined.  GCC doesn't inline
> them
> into main() because it knows they are executed exactly once which means they
> are cold and thus code growth doesn't outweight performance increase.
> 
> With -Winline you see:
> 
> t.C: In function ‘int main()’:
> t.C:31:1: warning: inlining failed in call to ‘void DisplayViewType(const
> ViewType&)’: call is unlikely and code size would grow [-Winline]
>  DisplayViewType( const ViewType& view ) {
>  ^~~~~~~~~~~~~~~
> t.C:38:20: note: called from here
>      DisplayViewType( ViewType::view2( data ) );
>      ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
> t.C:31:1: warning: inlining failed in call to ‘void DisplayViewType(const
> ViewType&)’: call is unlikely and code size would grow [-Winline]
>  DisplayViewType( const ViewType& view ) {
>  ^~~~~~~~~~~~~~~
> t.C:37:20: note: called from here
>      DisplayViewType( ViewType::view1( data ) );
>      ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> of course in the end the size heuristics are off and inlining would reduce
> code size.

The new version I uploaded moves the code out of main.  I just generated the
Assembly output for the new source code version and GCC still does not expand
it inline.

Reply via email to