-fomit-frame-pointer interaction with alloca - egcs-1.0.1

John Hughes john@AtlanTech.COM
Fri Feb 6 02:42:00 GMT 1998


John> My problem is that in the presence of [alloca] -fomit-frame-pointer
John> generates WORSE code, instead of just being ignored.

Jeffrey> Now that's a suprise!

Here's one (small) example:

	int test (int p) {
	        char *s = alloca (p);
	        fred (s);
	        return 1;
	}

Note that the code with -fomit-frame-pointer (on the right) has an unnecessary
"addl $4,%esp".  Not a huge difference, but why?

        .file   "test9.c"                       .file   "test9.c"
        .version        "01.01"                 .version        "01.01"
/ GNU C version egcs-2.90.23 980102 (   / GNU C version egcs-2.90.23 980102 (
/ options passed:  -O                 | / options passed:  -O -fomit-frame-po
/ options enabled:  -fdefer-pop -fthr | / options enabled:  -fdefer-pop -fomi
/ -finline -fkeep-static-consts -fpcc | / -fpeephole -ffunction-cse -finline
/ -fgnu-linker -falias-check -fargume | / -fpcc-struct-return -fcommon -fverb
/ -mno-soft-float -mieee-fp -mfp-ret- | / -fargument-alias -m80387 -mhard-flo
/ -march=pentium                      | / -mfp-ret-in-387 -mschedule-prologue

gcc2_compiled.:                         gcc2_compiled.:
.text                                   .text
        .align 4                                .align 4
.globl test                             .globl test
        .type    test,@function                 .type    test,@function
test:                                   test:
        pushl %ebp                              pushl %ebp
        movl %esp,%ebp                          movl %esp,%ebp
        movl 8(%ebp),%eax                       movl 8(%ebp),%eax
        addl $3,%eax                            addl $3,%eax
        andb $252,%al                           andb $252,%al
        subl %eax,%esp                          subl %eax,%esp
        pushl %esp                              pushl %esp
        call fred                               call fred
        movl $1,%eax                            movl $1,%eax
                                      >         addl $4,%esp
        leave                                   leave
        ret                                     ret
.Lfe1:                                  .Lfe1:
        .size    test,.Lfe1-test                .size    test,.Lfe1-test
        .ident  "GCC: (GNU) egcs-2.90           .ident  "GCC: (GNU) egcs-2.90

-- 
John Hughes <john@AtlanTech.COM>,
	Atlantic Technologies Inc.	Tel: +33-1-43204546
	24 rue Montbrun,		 Fax: +33-1-43204579
	75014 PARIS.




More information about the Gcc-bugs mailing list