This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, i386]: FIx PR target/12329, x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer
- From: rridge at csclub dot uwaterloo dot ca (Ross Ridge)
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 21 Mar 2008 16:49:42 -0400 (EDT)
- Subject: Re: [PATCH, i386]: FIx PR target/12329, x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer
Uros Bizjak writes:
>Attached patch fixes a couple of cases where %ecx register gets
>corrupted wher regparm(3) is in effect. The patch limits the number of
>regparms to 2 to preserve %ecx in these corner cases.
Consider this case:
int __attribute__((regparm(3))) foo(int a, int b, int c);
int bar() {
return foo(1, 2, 3)
}
int __attriubte__((regparm(3), force_align_arg_pointer))
foo(int a, int b, int c) {
return a + b + c;
}
Won't your patch result in foo() being called with three parameters in
registers, despite foo() only expecting two parameters to be in registers?
I don't think silently changing the calling convention is a good idea.
If the regparm(3) attribute can't be honoured it should result in
an error. The function might be called from assembly or code compiled
from some future version of GCC that does honour regparm(3) in this case.
Ross Ridge