This is the mail archive of the gcc-patches@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: Question about patch for PR bootstrap/65150 (identical functions)


On Fri, May 08, 2015 at 01:09:52PM -0600, Jeff Law wrote:
> On 05/08/2015 01:07 PM, David Edelsohn wrote:
> >>>>Steve Ellcey wrote:
> >>
> >>After your change GCC sees that the code for f1 and f2 are identical
> >>so it replaced the body of f2 with a call to f1.  This optimization will
> >>save space but it is not going to be faster because any call to f2 will
> >>now include an extra call/return.  Do other platforms have this same issue
> >>or is there a way to make f2 an alias for f1 on other targets so no extra
> >>call is needed?  I looked around to see if there was a target function or
> >>macro that is used to make one function an alias of another but I didn't
> >>see anything.
> >
> >This probably is not good for POWER, and probably not for ARM, in fact
> >probably not good for most RISC architectures.
> But isn't this code going to be creating aliases when the output format
> supports them -- which avoids the call/return overheads?
> 
> Which might argue that if we don't have aliases, then ICF might need to be a
> -Os thing.

ICF uses aliases only when possible (when it can prove that the callers
don't care about function address equality/non-equality.  In other cases
ICF uses caller redirection (if it is possible to redirect all callers and
remove unused other call), or thunks (otherwise).

Thunks indeed can slow things down somewhat, especially if they can't tail
call the function.

	Jakub


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