This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [PATCH, i386]: FIx PR target/12329, x86: local function declared with attribute((regparm(3))) gets corrupted parent frame pointer


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.


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