This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/15529] New: Use of regparm inhibits tail call optimization
- From: "cesarb at nitnet dot com dot br" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 May 2004 22:56:57 -0000
- Subject: [Bug rtl-optimization/15529] New: Use of regparm inhibits tail call optimization
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
(I would have put this in the right optimization component if I knew which of
them applies. Worse, bugzilla requires it. Let me take a guess... 50/50
chance... RTL?)
This is bug 14909 plus regparm. The testcase of bug 14909 works as expected.
When compiling:
//void g(void (*f)(void)) { f(); }
#define regparm __attribute__((regparm(3)))
void regparm g(void (regparm *f)()) { f(); }
With:
gcc -W -Wall -O3 -ffast-math -fomit-frame-pointer -fexpensive-optimizations
-save-temps -march=athlon -c
(most switches probably a red herring, didn't reduce the command line)
The result is:
.file "testcase.c"
.text
.align 4
.p2align 4,,15
.globl g
.type g, @function
g:
subl $12, %esp
call *%eax
addl $12, %esp
ret
.size g, .-g
.ident "GCC: (GNU) 3.5.0 20040502 (experimental)"
.section .note.GNU-stack,"",@progbits
It should be:
g:
jmp *%eax
The use of regparm is superfluous in this case, but the bug happens also in the
slightly less reduced testcase:
#define regparm __attribute__((regparm(3)))
void regparm g(void (regparm *f)(unsigned)) { f(0); }
Output:
.file "testcase2.c"
.text
.align 4
.p2align 4,,15
.globl g
.type g, @function
g:
subl $12, %esp
movl %eax, %edx
xorl %eax, %eax
call *%edx
addl $12, %esp
ret
.size g, .-g
.ident "GCC: (GNU) 3.5.0 20040502 (experimental)"
.section .note.GNU-stack,"",@progbits
The same happens when returning other than void (original testcase used
unsigned) -- same as bug 14909 in fact.
Reading specs from /usr/lib/gcc-snapshot/lib/gcc/i486-linux/3.5.0/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,objc,ada,treelang
--prefix=/usr/lib/gcc-snapshot --enable-shared --with-system-zlib --enable-nls
--enable-threads=posix --without-included-gettext --disable-werror
--enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug
--enable-java-gc=boehm --enable-java-awt=gtk i486-linux
Thread model: posix
gcc version 3.5.0 20040502 (experimental)
--
Summary: Use of regparm inhibits tail call optimization
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: cesarb at nitnet dot com dot br
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15529