This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Inline limitation?
- To: yumf at ultimatech dot com (Marco Manfai Yu)
- Subject: Re: Inline limitation?
- From: Joe Buck <jbuck at synopsys dot com>
- Date: Thu, 20 Aug 98 0:51:13 PDT
- Cc: ncm at nospam dot cantrip dot org, egcs at cygnus dot com
> There is such a warning, -Winline. I am not a compiler guru so I don't
> know how difficult it is to do inline regardless of the order of
> definition and use of functions. I know that our Sun C++ Version 4.2
> does inlining regardless of the order of definition.
No, Sun's compiler is not omniscient and can't always inline regardless of
the order of definition (though it evidently can inline in a couple of
cases where g++ cannot).
> This is very helpful in C++ because there are a lot of short,
> inlinable functions but the order of #includes forbids a
> define-before-use ordering. So egcs is losing a big opportunity
> to optimize here.
I doubt it. You may be forming the mistaken impression that g++ can
never inline a function that appears after its call, however in at least
some cases it can (e.g for functions defined in the class declaration, to
a limited degree).
If you are worried that you are losing optimization, turn on -Winline,
which will tell you which functions cannot be inlined. You could then try
reordering only the most important calls.