This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: On inlining in C++


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]