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: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "Ross Ridge" <rridge at csclub dot uwaterloo dot ca>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 22 Mar 2008 13:31:54 +0100
- Subject: Re: [PATCH, i386]: FIx PR target/12329, x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer
- References: <20080321204942.99B1573DAF@caffeine.csclub.uwaterloo.ca>
On Fri, Mar 21, 2008 at 9:49 PM, Ross Ridge <rridge@csclub.uwaterloo.ca> wrote:
> 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.
I agree. Only if gcc decides itself to use register passing conventions it is
free to limit the amount of registers used. With an explicit regparm() it
should be either honored or an error.
Richard.