This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

asm conflicts with the frame pointer are not diagnosed



Compiling this simple example on ia32 with -O2 (and without 
-fomit-frame-pointer) with gcc current 990902:

/* bla will clobber all registers, including %ebp */ 
static inline int foo(int bla)
{
        int ret; 
        asm volatile("pushl %0\n\t"
            "call bla\n\t"
            "addl $4,%%esp"
        : /* outputs */ "=&a" (ret) 
        : /* inputs */ "0" (bla)
        : /* clobber */ "bx", "cx", "dx", "si", "dx", "bp","cc", "memory" ); 
        return ret; 
}

int t(int i) { return foo(i); } 

gives

	.file	"t.c"
	.version	"01.01"
gcc2_compiled.:
.text
	.align 16
.globl t
	.type	 t,@function
t:
	pushl	%ebp
	movl	%esp, %ebp
	pushl	%esi
	pushl	%ebx
	movl	8(%ebp), %eax
                                  <--- no attempt to save %ebp here
#APP
	pushl %eax
	call bla
	addl $4,%esp
#NO_APP
	popl	%ebx
	popl	%esi
	movl	%ebp, %esp        <--- restore the clobbered %ebp to stack
	popl	%ebp                   --> crash
	ret
.Lfe1:
	.size	 t,.Lfe1-t

[egcs 1.1 has the same problem]

With -fomit-frame-pointer it works fine, but I find it seems it does not
handle asm clobber specifications that conflict with the frame pointer
and silently generates bad code. At least a diagnostic would be useful,
wouldn't it?


-Andi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]