Bug 19599 - function pointer prevents tail-call optimization on arm
Summary: function pointer prevents tail-call optimization on arm
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.0.0
: P2 enhancement
Target Milestone: 4.9.0
Assignee: Ramana Radhakrishnan
URL:
Keywords: missed-optimization, patch
Depends on:
Blocks:
 
Reported: 2005-01-24 00:19 UTC by Philip Blundell
Modified: 2013-05-16 08:29 UTC (History)
3 users (show)

See Also:
Host:
Target: arm-linux
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-09-09 14:29:50


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philip Blundell 2005-01-24 00:19:47 UTC
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
Comment 1 Andrew Pinski 2005-01-24 00:24:16 UTC
Since tail call is now down at the tree level (except for expansion which is where the problem is), this is 
a target bug.
Comment 2 Ramana Radhakrishnan 2009-04-21 14:29:50 UTC
Mine.
Comment 3 Ramana Radhakrishnan 2009-06-04 12:39:30 UTC
Patch submitted here. http://gcc.gnu.org/ml/gcc-patches/2009-06/msg00373.html
Comment 4 Steven Bosscher 2010-02-08 11:22:00 UTC
Patch of comment #3 from Ramana was never committed to the trunk.
Comment 5 Steven Bosscher 2011-09-09 14:55:20 UTC
Ping Ramana.
Comment 6 Ramana Radhakrishnan 2011-09-09 16:29:22 UTC
>
> --- Comment #5 from Steven Bosscher <steven at gcc dot gnu.org> 2011-09-09 14:55:20 UTC ---
> Ping Ramana.

Sigh - yes will look into this .

Ramana
>
> --
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are the assignee for the bug.
>
Comment 7 Ramana Radhakrishnan 2011-09-30 09:57:06 UTC
The patch as applied today causes some bootstrap failures and I'm investigating that.

Ramana
Comment 8 Ramana Radhakrishnan 2013-05-16 08:29:57 UTC
http://gcc.gnu.org/ml/gcc-cvs/2013-05/msg00449.html

Fixed on trunk. 

Ramana