public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: BUG: GCC-4.4.x changes the function frame on some functions
@ 2009-11-19 20:50 H. Peter Anvin
  0 siblings, 0 replies; 99+ messages in thread
From: H. Peter Anvin @ 2009-11-19 20:50 UTC (permalink / raw)
  To: Frederic Weisbecker, Steven Rostedt
  Cc: David Daney, Linus Torvalds, Andrew Haley, Richard Guenther,
	Thomas Gleixner, Ingo Molnar, LKML, Andrew Morton,
	Heiko Carstens, feng.tang, Peter Zijlstra, jakub, gcc

[-- Attachment #1: Type: text/plain, Size: 2814 bytes --]

On i386, if we call __fentry__ immediately on entry the return address will be in 4(%esp), so I fail to see how you could not reliably have the return address.  Other arches would have different constraints, of course.

"Frederic Weisbecker" <fweisbec@gmail.com> wrote:

>On Thu, Nov 19, 2009 at 03:05:41PM -0500, Steven Rostedt wrote:
>> On Thu, 2009-11-19 at 20:46 +0100, Frederic Weisbecker wrote:
>> > On Thu, Nov 19, 2009 at 02:28:06PM -0500, Steven Rostedt wrote:
>> 
>> > > 	<function>:
>> > > 		call __fentry__
>> > > 		[...]
>> > > 
>> > > 	
>> > > -- Steve
>> > 
>> > 
>> > I would really like this. So that we can forget about other possible
>> > further suprises due to sophisticated function prologues beeing before
>> > the mcount call.
>> > 
>> > And I guess that would fix it in every archs.
>> 
>> Well, other archs use a register to store the return address. But it
>> would also be easy to do (pseudo arch assembly):
>> 
>> 	<function>:
>> 		mov lr, (%sp)
>> 		add 8, %sp
>> 		blr __fentry__
>> 		sub 8, %sp
>> 		mov (%sp), lr
>> 
>> 
>> That way the lr would have the current function, and the parent would
>> still be at 8(%sp)
>> 
>
>
>Yeah right, we need at least such very tiny prologue for
>archs that store return addresses in a reg.
>
>	
>> > 
>> > That said, Linus had a good point about the fact there might other uses
>> > of mcount even more tricky than what does the function graph tracer,
>> > outside the kernel, and those may depend on the strict ABI assumption
>> > that 4(ebp) is always the _real_ return address, and that through all
>> > the previous stack call. This is even a concern that extrapolates the
>> > single mcount case.
>> 
>> As I am proposing a new call. This means that mcount stay as is for
>> legacy reasons. Yes I know there exists the -finstrument-functions but
>> that adds way too much bloat to the code. One single call to the
>> profiler is all I want.
>
>
>Sure, the purpose is not to change the existing -mcount thing.
>What I meant is that we could have -mcount and -real-ra-before-fp
>at the same time to guarantee fp + 4 is really what we want while
>using -mcount.
>
>The __fentry__ idea is more neat, but the guarantee of a real pointer
>to the return address is still something that lacks.
>
>
>> > 
>> > So I wonder that actually the real problem is the lack of something that
>> > could provide this guarantee. We may need a -real-ra-before-fp (yeah
>> > I suck in naming).
>> 
>> Don't worry, so do the C compiler folks, I mean, come on "mcount"?
>
>
>I guess it has been first created for the single purpose of counting
>specific functions but then it has been used for wider, unpredicted uses :)
>

--
Sent from my mobile phone. Please excuse any lack of formatting.

^ permalink raw reply	[flat|nested] 99+ messages in thread
* Re: BUG: GCC-4.4.x changes the function frame on some functions
@ 2009-11-19 21:16 H. Peter Anvin
  2009-11-19 21:26 ` Jeff Law
  0 siblings, 1 reply; 99+ messages in thread
From: H. Peter Anvin @ 2009-11-19 21:16 UTC (permalink / raw)
  To: Jeff Law
  Cc: rostedt, David Daney, Linus Torvalds, Andrew Haley,
	Richard Guenther, Thomas Gleixner, Ingo Molnar, LKML,
	Andrew Morton, Heiko Carstens, feng.tang, Fr??d??ric Weisbecker,
	Peter Zijlstra, jakub, gcc

[-- Attachment #1: Type: text/plain, Size: 728 bytes --]

Hence a new unconstrained option...

"Jeff Law" <law@redhat.com> wrote:

>On 11/19/09 12:50, H. Peter Anvin wrote:
>>
>> Calling the profiler immediately at the entry point is clearly the more
>> sane option.  It means the ABI is well-defined, stable, and independent
>> of what the actual function contents are.  It means that ABI isn't the
>> normal C ABI (the __fentry__ function would have to preserve all
>> registers), but that's fine...
>>    
>Note there are targets (even some old x86 variants) that required the 
>profiling calls to occur after the prologue.  Unfortunately, nobody 
>documented *why* that  was the case.   Sigh.
>
>Jeff

--
Sent from my mobile phone. Please excuse any lack of formatting.

^ permalink raw reply	[flat|nested] 99+ messages in thread

end of thread, other threads:[~2009-11-25 21:01 UTC | newest]

Thread overview: 99+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <alpine.LFD.2.00.0911181933540.24119@localhost.localdomain>
     [not found] ` <tip-887a29f59b93cf54e21814869a4ab6e80b6fa623@git.kernel.org>
     [not found]   ` <20091119072040.GA23579@elte.hu>
     [not found]     ` <alpine.LFD.2.00.0911191053390.24119@localhost.localdomain>
     [not found]       ` <alpine.LFD.2.00.0911191423190.24119@localhost.localdomain>
2009-11-19 15:39         ` BUG: GCC-4.4.x changes the function frame on some functions Thomas Gleixner
2009-11-19 15:45           ` Andrew Haley
2009-11-19 15:55             ` H. Peter Anvin
2009-11-19 15:59               ` Richard Guenther
2009-11-19 16:03             ` Steven Rostedt
2009-11-19 16:13               ` H. Peter Anvin
2009-11-19 16:20               ` Frederic Weisbecker
2009-11-19 16:07             ` Thomas Gleixner
2009-11-19 16:19               ` Andrew Haley
2009-11-19 16:45                 ` Thomas Gleixner
2009-11-19 16:13             ` Steven Rostedt
2009-11-19 15:46           ` H. Peter Anvin
2009-11-19 15:51             ` Richard Guenther
2009-11-19 15:53               ` Richard Guenther
2009-11-19 17:38               ` Andi Kleen
2009-11-19 17:41           ` Linus Torvalds
2009-11-19 17:52             ` Thomas Gleixner
2009-11-19 18:00             ` Steven Rostedt
2009-11-19 18:04               ` Richard Guenther
2009-11-19 18:23                 ` Andrew Haley
2009-11-19 18:42                   ` Linus Torvalds
2009-11-19 18:45                     ` Linus Torvalds
2009-11-19 18:56                       ` Linus Torvalds
2009-11-19 19:03                         ` Thomas Gleixner
2009-11-23  9:17                           ` Jakub Jelinek
2009-11-23  9:53                             ` Thomas Gleixner
2009-11-19 19:12                         ` David Daney
2009-11-19 19:29                           ` Steven Rostedt
2009-11-19 19:47                             ` Frederic Weisbecker
2009-11-19 19:55                               ` Kai Tietz
2009-11-19 20:06                                 ` Frederic Weisbecker
2009-11-19 20:06                               ` Steven Rostedt
2009-11-19 20:18                                 ` Steven Rostedt
2009-11-19 20:29                                   ` Frederic Weisbecker
2009-11-19 20:26                                 ` Frederic Weisbecker
2009-11-19 20:38                                   ` Linus Torvalds
2009-11-19 20:45                                     ` Steven Rostedt
2009-11-19 19:51                             ` H. Peter Anvin
2009-11-19 20:08                               ` Linus Torvalds
2009-11-19 21:13                                 ` Jeff Law
2009-11-19 20:11                               ` Steven Rostedt
2009-11-19 21:07                               ` Jeff Law
2009-11-19 18:34                 ` Thomas Gleixner
2009-11-19 18:40                 ` Linus Torvalds
2009-11-19 18:48                   ` Ingo Molnar
2009-11-19 19:08                     ` Steven Rostedt
2009-11-19 19:51                       ` Ingo Molnar
2009-11-20  9:58                       ` [PATCH] gcc mcount-nofp was " Andi Kleen
2009-11-20 12:35                         ` Steven Rostedt
2009-11-20 19:08                           ` H. Peter Anvin
2009-11-19 20:37                   ` Thomas Gleixner
2009-11-19 18:22           ` Andrew Haley
2009-11-19 18:34             ` Steven Rostedt
2009-11-19 18:37               ` Andrew Pinski
2009-11-19 18:38               ` H. Peter Anvin
2009-11-19 18:38               ` Andrew Haley
2009-11-19 18:40             ` Thomas Gleixner
2009-11-20  5:24         ` [PATCH][GIT PULL][v2.6.32] tracing/x86: Add check to detect GCC messing with mcount prologue Steven Rostedt
2009-11-20  5:33           ` Steven Rostedt
2009-11-20 17:02           ` Steven Rostedt
2009-11-20 17:15             ` H. Peter Anvin
2009-11-20 19:36             ` Andrew Haley
2009-11-20 19:48               ` Steven Rostedt
2009-11-20 19:50                 ` H. Peter Anvin
2009-11-22  9:39               ` H.J. Lu
2009-11-22 17:21                 ` Andrew Haley
2009-11-22 23:31                   ` H.J. Lu
2009-11-24 14:43                     ` Andrew Haley
2009-11-24 14:56                       ` Thomas Gleixner
2009-11-24 15:06                         ` Jakub Jelinek
2009-11-24 15:32                           ` Andrew Haley
2009-11-24 15:36                             ` Jakub Jelinek
2009-11-24 15:48                               ` Andrew Haley
2009-11-24 16:39                                 ` H. Peter Anvin
2009-11-24 17:12                                   ` Andrew Haley
2009-11-24 17:30                                     ` Steven Rostedt
2009-11-25 20:05                                       ` H. Peter Anvin
2009-11-24 19:56                                     ` H. Peter Anvin
2009-11-25 15:29                           ` Thomas Gleixner
2009-11-25 15:45                             ` Ingo Molnar
2009-11-25 15:53                               ` Thomas Gleixner
2009-11-25 16:26                                 ` Ingo Molnar
2009-11-25 16:45                               ` Jakub Jelinek
2009-11-25 20:13                                 ` H. Peter Anvin
2009-11-25 21:01                                   ` Andrew Haley
2009-11-22  9:06             ` Ingo Molnar
2009-11-19 20:50 BUG: GCC-4.4.x changes the function frame on some functions H. Peter Anvin
2009-11-19 21:16 H. Peter Anvin
2009-11-19 21:26 ` Jeff Law
2009-11-19 22:44   ` Steven Rostedt
2009-11-20  0:00     ` Jeff Law
2009-11-20  0:37       ` Thomas Gleixner
2009-11-20  1:00         ` Linus Torvalds
2009-11-20  1:29           ` Thomas Gleixner
2009-11-20  2:16             ` Thomas Gleixner
2009-11-20  1:30           ` H. Peter Anvin
2009-11-20  5:40           ` Ingo Molnar
2009-11-20 12:06         ` Andrew Haley
2009-11-20 12:23           ` Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).