public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, AVR]: Fix thinko in avr_function_arg_advance
@ 2011-06-09 19:02 Georg-Johann Lay
  2011-06-09 19:03 ` Denis Chertykov
  0 siblings, 1 reply; 2+ messages in thread
From: Georg-Johann Lay @ 2011-06-09 19:02 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eric B. Weddington, Anatoly Sokolov, Denis Chertykov

[-- Attachment #1: Type: text/plain, Size: 672 bytes --]

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.


[-- Attachment #2: thinko-avr_function_arg_advance.diff --]
[-- Type: text/x-patch, Size: 854 bytes --]

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;
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch, AVR]: Fix thinko in avr_function_arg_advance
  2011-06-09 19:02 [Patch, AVR]: Fix thinko in avr_function_arg_advance Georg-Johann Lay
@ 2011-06-09 19:03 ` Denis Chertykov
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Chertykov @ 2011-06-09 19:03 UTC (permalink / raw)
  To: Georg-Johann Lay; +Cc: gcc-patches, Eric B. Weddington, Anatoly Sokolov

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-09 18:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-09 19:02 [Patch, AVR]: Fix thinko in avr_function_arg_advance Georg-Johann Lay
2011-06-09 19:03 ` Denis Chertykov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).