This code:
int g(int);
int f(int x)
{
return g(x);
}
is correctly compiled to just
f:
b g
But, if g is a function pointer:
int (*g)(int);
int f(int x)
{
return g(x);
}
then the generated code becomes much less efficient:
f:
str lr, [sp, #-4]!
ldr r3, .L3
mov lr, pc
ldr pc, [r3, #0]
ldr pc, [sp], #4
--
Summary: function pointer prevents tail-call optimisation
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pb at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: arm-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19599