(i386-linux x sh-elf) Unnecessary stack adjusts generated for function calls
Toshiyasu Morita
tm@netcom.com
Mon Jun 19 22:32:00 GMT 2000
version: CVS
host: i386-linux
target: sh-elf
For some reason, gcc has started to generate unnecessary
stack adjusts before and after most function calls.
For example, when the following code is compiled:
oid func(int foo)
{
func2(foo);
}
using the options:
-O2 -m4-single-only -ml -S -g
the following code is generated:
func:
mov.l r14,@-r15
mov.l .L3,r1
sts.l pr,@-r15
mov r15,r14
jsr @r1
add #-4,r15 <- unnecessary stack adjust
mov r14,r15
lds.l @r15+,pr
rts
mov.l @r15+,r14
I initially noticed this while browsing the bzip2 decompressor output.
Here are a few samples from bzip2:
3032:./decompress.i **** } else {
3033:./decompress.i **** s->tt = (strm->bzalloc)(strm->opaque,( s->blockSize100k * 100000 * sizeof(Int32) ),1) ;
756 0380 46D1 mov.l .L704,r1
757 0382 FC7F add #-4,r15 <- here
758 0384 D954 mov.l @(36,r13),r4
759 0386 01E6 mov #1,r6
3034:./decompress.i **** if (s->tt == ((void *)0) ) { retVal = (-3) ; goto save_state_and_return; }; ;
762 0388 FDEA mov #-3,r10
765 038a 1702 mul.l r1,r2
766 038c D751 mov.l @(28,r13),r1
767 038e 0B41 jsr @r1
768 0390 1A05 sts macl,r5
769 0392 0361 mov r0,r1
...
3054:./decompress.i **** fprintf(((_IO_FILE*)(&_IO_stderr_)) , "\n [%d: huff+mtf " , s->currBlockNo ) ;
1136 0624 4ED1 mov.l .L707,r1
1137 0626 4FD5 mov.l .L708,r5
1138 0628 4FD4 mov.l .L709,r4
1139 062a 0B41 jsr @r1
1140 062c FC7F add #-4,r15 <- here
1141 062e 047F add #4,r15 <- here
...
1759 .L183:
1760 0a8c 017B add #1,r11
1761 0a8e 0FE1 mov #15,r1
1762 0a90 173B cmp/gt r1,r11
1763 0a92 B18B bf .L184
1764 0a94 FC7F add #-4,r15 <- here
3091:./decompress.i **** }
3092:./decompress.i **** makeMaps_d ( s );
1767 0a96 2CD1 mov.l .L717,r1
1768 0a98 0B41 jsr @r1
...
3879 16da 9C51 mov.l @(48,r9),r1
3880 16dc 2731 cmp/gt r2,r1
3881 16de 058B bf .L426
3882 16e0 63D1 mov.l .L779,r1
3883 16e2 64D5 mov.l .L780,r5
3884 16e4 64D4 mov.l .L781,r4
3885 16e6 0B41 jsr @r1
3886 16e8 FC7F add #-4,r15 <- here
3887 16ea 047F add #4,r15 <- here
3888 .L426:
3293:./decompress.i ****
3294:./decompress.i ****
3295:./decompress.i **** s->cftab[0] = 0;
...
3326:./decompress.i **** s->k0 = indexIntoF ( s->tPos, s->cftab ); s->tPos = (((UInt32)s->ll16[ s->tPos ]) | (
4201 18b0 67D1 mov.l .L792,r1
4202 18b2 FC7F add #-4,r15 <- here
4203 18b4 C695 mov.w .L793,r5
4206 18b6 2519 mov.l r2,@(20,r9)
4207 18b8 2619 mov.l r2,@(24,r9)
4210 18ba 9C35 add r9,r5
4211 18bc 0B41 jsr @r1
...
3329:./decompress.i **** s->k0 = indexIntoF ( s->tPos, s->cftab ); s->tPos = (((UInt32)s->ll16[ s->tPos ]) | (
4254 1900 53D1 mov.l .L792,r1
4255 1902 FC7F add #-4,r15 <- here
4256 1904 9E95 mov.w .L793,r5
4257 1906 9E54 mov.l @(56,r9),r4
4258 1908 0B41 jsr @r1
4259 190a 9C35 add r9,r5
4260 190c 9B91 mov.w .L794,r1
...
3383:./decompress.i **** default: { if (!( ((Bool)0) )) bz__AssertH__fail ( 4001 ); } ;
4971 1e00 2BD8 mov.l .L803,r8
4972 1e02 5394 mov.w .L804,r4
4973 1e04 0B48 jsr @r8
4974 1e06 FC7F add #-4,r15 <- here
3384:./decompress.i **** }
3385:./decompress.i ****
3386:./decompress.i **** { if (!( ((Bool)0) )) bz__AssertH__fail ( 4002 ); } ;
4977 1e08 5194 mov.w .L805,r4
4978 1e0a 0B48 jsr @r8
4979 1e0c 0900 nop
4980 1e0e 047F add #4,r15 <- here
...
Toshi
More information about the Gcc-bugs
mailing list