This is the mail archive of the 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: Forbid __builtin_return_address when inlining

Mark Mitchell writes:
 > Andrew Haley wrote:
 > > Mark Mitchell writes:
 > >  > Andrew Haley wrote:
 > >  > > __builtin_return_address(0) returns the wrong address if its caller
 > >  > > has been inlined.  Weirdly, we never seem to have detected this
 > >  > > before, but it surely must be wrong.
 > >  > 
 > >  > The manual says:
 > >  > 
 > >  > >  When
 > >  > >      inlining the expected behavior is that the function will return
 > >  > >      the address of the function that will be returned to.  To work
 > >  > >      around this behavior use the `noinline' function attribute.
 > >  > 
 > >  > which seems to suggest that the behavior you are seeing as is
 > >  > documented, peculiar though it seems.
 > > 
 > > Hmm, OK.  But if I fixed the peculiar behavour then I could also
 > > remove the peculiar documentation, couldn't I?  That would surely be
 > > an improvement.,,
 > The problem is that we don't know how people may already be using
 > this "feature".  Since someone bothered to document it, I wouldn't
 > be surprised if something (the Linux kernel?  a scripting language
 > interpreter?) is using it in some way that depends on the current
 > behavior.

No kidding.  Yes, that's surely possible.

 > So, I fully agree that the semantics you're proposing seem more
 > sensible (i.e., tell me where *this function* returns, and, if
 > necessary, make sure that it has somewhere to return to by not
 > inlining it), but I'd be nervous about making the change.  Is there
 > a compelling reason to change this, other than just that it makes
 > sense?

No, not really.  Java methods sometimes need to find their caller, and
I was testing that when I discovered this anomalous behaviour when a
method was being inlined.  The most obvious solution is for the Java
FE to mark the methods that need to find their caller noinline, and
that's what I'll do.


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