This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: On inlining in C++
- From: Diego Novillo <dnovillo at redhat dot com>
- To: Joe Buck <jbuck at synopsys dot com>
- Cc: Geoff Keating <geoffk at geoffk dot org>, Gabriel Dos Reis <gdr at integrable-solutions dot net>, Andrew Haley <aph at redhat dot com>, coyote at coyotegulch dot com, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Mon, 15 Dec 2003 13:30:03 -0500
- Subject: Re: On inlining in C++
- Organization: Red Hat Canada
- References: <20030805174954.0295AF2D96@nile.gnat.com> <m31xw07zub.fsf@uniton.integrable-solutions.net> <jmispcvujr.fsf@desire.geoffk.org> <20030805190007.A1778@synopsys.com>
On Tue, 2003-08-05 at 22:00, Joe Buck wrote:
> Compile the following code with "gcc -O2 -S il.C" using the trunk on x86,
> and take a look. The problem is that we prematurely commit the tmp object
> to the stack, even though after inlining its address is not taken.
>
> --------------------------------------
> struct bar { int i; int j;};
>
> #define MACRO(foo) (foo).i + (foo).j
>
> inline int func(const bar& foo) {
> return foo.i + foo.j;
> }
>
> int call_macro()
> {
> bar tmp;
> tmp.i = 1;
> tmp.j = 2;
> return MACRO(tmp);
> }
>
> int call_func()
> {
> bar tmp;
> tmp.i = 1;
> tmp.j = 2;
> return func(tmp);
> }
> --------------------------------------
>
Much later than I would've wanted, but this is fixed now on tree-ssa.
Both functions are optimized into 'return 3;'.
Diego.