Question About New Option '-fipa-sra': How Does It Work?

Tom Browder
Mon Sep 6 13:21:00 GMT 2010

On Wed, Apr 14, 2010 at 10:52, Tom Browder <> wrote:
> On Tue, Apr 13, 2010 at 17:00, Kevin P. Fleming <> wrote:
>> Tom Browder wrote:
>>> I see the new -fipa-sra option for gcc 4.5 and its explanation and
>>> wonder how replacing an argument passed by reference with an argument
>>> passed by value is an optimization (I assume something magic is going
>>> on behind the scenes).
>> Well... a pointer to an int on an x86-64 platform is 8 bytes on the
>> stack instead of 4, and slower access to the contents of the int. If the
>> int is never modified in the called function, passing a copy of the int
>> on the stack instead is clearly a win.
> Thanks, Kevin, I was asleep--I immediately thought of structures and
> containers--duh!
> (But perhaps the text could be more explicitly worded for us dense heads.)

Here is the exact text from the texi source on the trunk:

@item -fipa-sra
@opindex fipa-sra
Perform interprocedural scalar replacement of aggregates, removal of
unused parameters and replacement of parameters passed by reference
by parameters passed by value.

I suggest something like:

Perform inter-procedural optimization of function arguments: (1) scalar
replacement of aggregates by references, (2) removal of unused
parameters, and (3) replacement of const scalar parameters passed by
reference by parameters passed by value.  The changes are made in
the object code, but such changes result in warnings to stdout.

Note that the warnings are given now (at least in v 4.5.1) but I think
that would be a  good feature (perhaps optional).




Thomas M. Browder, Jr.
Niceville, Florida

More information about the Gcc-help mailing list