This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: BUG: GCC-4.4.x changes the function frame on some functions
- From: Ingo Molnar <mingo at elte dot hu>
- To: Steven Rostedt <rostedt at goodmis dot org>
- Cc: Linus Torvalds <torvalds at linux-foundation dot org>, Richard Guenther <richard dot guenther at gmail dot com>, Thomas Gleixner <tglx at linutronix dot de>, "H. Peter Anvin" <hpa at zytor dot com>, LKML <linux-kernel at vger dot kernel dot org>, Andrew Morton <akpm at linux-foundation dot org>, Heiko Carstens <heiko dot carstens at de dot ibm dot com>, feng dot tang at intel dot com, Fr??d??ric Weisbecker <fweisbec at gmail dot com>, Peter Zijlstra <peterz at infradead dot org>, jakub at redhat dot com, gcc at gcc dot gnu dot org
- Date: Thu, 19 Nov 2009 20:50:15 +0100
- Subject: Re: BUG: GCC-4.4.x changes the function frame on some functions
- References: <20091119072040.GA23579@elte.hu> <alpine.LFD.2.00.0911191053390.24119@localhost.localdomain> <alpine.LFD.2.00.0911191423190.24119@localhost.localdomain> <alpine.LFD.2.00.0911191607440.24119@localhost.localdomain> <alpine.LFD.2.00.0911190934070.2793@localhost.localdomain> <1258653562.22249.682.camel@gandalf.stny.rr.com> <84fc9c000911191003t244eb864o3d5b355ab5485f@mail.gmail.com> <alpine.LFD.2.00.0911191026420.2793@localhost.localdomain> <20091119184716.GA25458@elte.hu> <1258657614.22249.824.camel@gandalf.stny.rr.com>
* Steven Rostedt <rostedt@goodmis.org> wrote:
> On Thu, 2009-11-19 at 19:47 +0100, Ingo Molnar wrote:
> > * Linus Torvalds <torvalds@linux-foundation.org> wrote:
> >
> > > Admittedly, anybody who compiles with -pg probably doesn't care deeply
> > > about smaller and more efficient code, since the mcount call overhead
> > > tends to make the thing moot anyway, but it really looks like a
> > > win-win situation to just fix the mcount call sequence regardless.
> >
> > Just a sidenote: due to dyn-ftrace, which patches out all mcounts during
> > bootup to be NOPs (and opt-in patches them in again if someone runs the
> > function tracer), the cost is not as large as one would have it with say
> > -pg based user-space profiling.
> >
> > It's not completely zero-cost as the pure NOPs balloon the i$ footprint
> > a bit and GCC generates different code too in some cases. But it's
> > certainly good enough that it's generally pretty hard to prove overhead
> > via micro or macro benchmarks that the patched out mcounts call sites
> > are there.
>
> And frame pointers do add a little overhead as well. Too bad the mcount
> ABI wasn't something like this:
>
>
> <function>:
> call mcount
> [...]
>
> This way, the function address for mcount would have been (%esp) and
> the parent address would be 4(%esp). Mcount would work without frame
> pointers and this whole mess would also become moot.
In that case we could also fix up static callsites to this address as
well (to jump +5 bytes into the function) and avoid the NOP as well in
most cases. (That would in essence merge any slow-path function epilogue
with the mcount cal instruction in terms of I$ footprint - i.e. it would
be an even lower overhead feature.)
If only the kernel had its own compiler.
Ingo