diff mbox

[AVR] : Fix thinko in avr_function_arg_advance

Message ID 4DF1149C.3000604@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay June 9, 2011, 6:44 p.m. UTC
This patch fixes a thinko in avr_function_arg_advance.

Without the patch, following code will report false positive for
passing args in fixed regs like:

error: Register r0 is needed to pass a parameter but is fixed
error: Register r1 is needed to pass a parameter but is fixed

This is the code:

typedef struct
{
    char c[18];
} S;

typedef struct
{
    char c[26];
} T;

char foo (S b, T a)
{
    return b.c[9];
}

The patch also uses same constraint for cfun->machine->sibcall_fails
(even though it would not hut to have false positived there).

Johann

--
	* config/avr/avr.c (avr_function_arg_advance): Fix thinko about
	when a value is actually passed in regs.

Comments

Denis Chertykov June 9, 2011, 6:55 p.m. UTC | #1
2011/6/9 Georg-Johann Lay <avr@gjlay.de>:
> This patch fixes a thinko in avr_function_arg_advance.
>
> Without the patch, following code will report false positive for
> passing args in fixed regs like:
>
> error: Register r0 is needed to pass a parameter but is fixed
> error: Register r1 is needed to pass a parameter but is fixed
>
> This is the code:
>
> typedef struct
> {
>    char c[18];
> } S;
>
> typedef struct
> {
>    char c[26];
> } T;
>
> char foo (S b, T a)
> {
>    return b.c[9];
> }
>
> The patch also uses same constraint for cfun->machine->sibcall_fails
> (even though it would not hut to have false positived there).

Approved.

Denis.
diff mbox

Patch

Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c	(Revision 174701)
+++ config/avr/avr.c	(Arbeitskopie)
@@ -1784,7 +1784,8 @@  avr_function_arg_advance (CUMULATIVE_ARG
      a function must not pass arguments in call-saved regs in order to get
      tail-called. */
   
-  if (cum->regno >= 0
+  if (cum->regno >= 8
+      && cum->nregs >= 0
       && !call_used_regs[cum->regno])
     {
       /* FIXME: We ship info on failing tail-call in struct machine_function.
@@ -1800,7 +1801,8 @@  avr_function_arg_advance (CUMULATIVE_ARG
      user has fixed a GPR needed to pass an argument, an (implicit) function
      call would clobber that fixed register.  See PR45099 for an example.  */
   
-  if (cum->regno >= 0)
+  if (cum->regno >= 8
+      && cum->nregs >= 0)
     {
       int regno;