public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/49666] New: passing nested function to inline function causes a trampoline call
@ 2011-07-07 3:46 kevin.waugh at gmail dot com
2011-07-07 9:22 ` [Bug tree-optimization/49666] " rguenth at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: kevin.waugh at gmail dot com @ 2011-07-07 3:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49666
Summary: passing nested function to inline function causes a
trampoline call
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: other
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: kevin.waugh@gmail.com
#include <stdio.h>
static inline int identity(int (*f)()) {
return f();
}
int n = 0;
int f() {
return n;
}
int main() {
int m = 0;
int g() {
return m;
}
printf("%d\n", identity(f)); /* inlines all the way */
printf("%d\n", identity(g)); /* calls g through trampoline */
printf("%d\n", g()); /* inline's g */
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/49666] passing nested function to inline function causes a trampoline call
2011-07-07 3:46 [Bug other/49666] New: passing nested function to inline function causes a trampoline call kevin.waugh at gmail dot com
@ 2011-07-07 9:22 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-07-07 9:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49666
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.07.07 09:22:08
Component|other |tree-optimization
Ever Confirmed|0 |1
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-07-07 09:22:08 UTC ---
We don't know how to "devirtualize" trampolines. In fact trampoline setup
isn't very SSA analyzer friendly (look at the hoops IPA points-to analysis
jumps through). We end up with
<bb 2>:
__builtin_init_trampoline (&FRAME.0.g, g, &FRAME.0);
FRAME.0.m = 0;
D.3251_20 = n;
printf (&"%d\n"[0], D.3251_20);
D.3230_3 = __builtin_adjust_trampoline (&FRAME.0.g);
D.3231_4 = (int (*<T50a>) (void)) D.3230_3;
D.3245_18 = D.3231_4 ();
printf (&"%d\n"[0], D.3245_18);
Now we could "devirtualize" the above based on the fact the trampoline
doesn't escape.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-07-07 9:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-07 3:46 [Bug other/49666] New: passing nested function to inline function causes a trampoline call kevin.waugh at gmail dot com
2011-07-07 9:22 ` [Bug tree-optimization/49666] " rguenth at gcc dot gnu.org
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).