public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch,AVR]: Fix PR45099
@ 2011-05-02 15:24 Georg-Johann Lay
  2011-05-02 16:19 ` Nathan Froyd
  0 siblings, 1 reply; 6+ messages in thread
From: Georg-Johann Lay @ 2011-05-02 15:24 UTC (permalink / raw)
  To: gcc-patches; +Cc: Anatoly Sokolov, Denis Chertykov, Eric Weddington

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

PR45099 is an extension that gives an error when a fixed register is
needed to pass a parameter to a function.

Because the program will show malfunction when such code is generated,
anyway, I think an error is more appropriate than a warning (as
proposed in the PR).

Johann

2011-05-02  Georg-Johann Lay  <avr@gjlay.de>

	PR target/45099

	* config/avr/avr.c (avr_function_arg_advance): Error if a fixed
	register is needed for a function argument.

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

Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c	(Revision 172902)
+++ config/avr/avr.c	(Arbeitskopie)
@@ -1794,6 +1794,20 @@ avr_function_arg_advance (CUMULATIVE_ARG
       cfun->machine->sibcall_fails = 1;
     }
 
+  /* Test if all registers needed by the ABI are actually available.  If the
+     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)
+    {
+      int regno;
+
+      for (regno = cum->regno; regno < cum->regno + bytes; regno++)
+        if (fixed_regs[regno])
+          error ("Register %s is needed to pass a parameter but is fixed",
+                 reg_names[regno]);
+    }
+      
   if (cum->nregs <= 0)
     {
       cum->nregs = 0;

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

* Re: [Patch,AVR]: Fix PR45099
  2011-05-02 15:24 [Patch,AVR]: Fix PR45099 Georg-Johann Lay
@ 2011-05-02 16:19 ` Nathan Froyd
  2011-05-06 14:07   ` Georg-Johann Lay
  0 siblings, 1 reply; 6+ messages in thread
From: Nathan Froyd @ 2011-05-02 16:19 UTC (permalink / raw)
  To: Georg-Johann Lay
  Cc: gcc-patches, Anatoly Sokolov, Denis Chertykov, Eric Weddington

On Mon, May 02, 2011 at 05:23:48PM +0200, Georg-Johann Lay wrote:
> PR45099 is an extension that gives an error when a fixed register is
> needed to pass a parameter to a function.
> 
> Because the program will show malfunction when such code is generated,
> anyway, I think an error is more appropriate than a warning (as
> proposed in the PR).

This seems like something that should be handled by common code.

-Nathan

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

* Re: [Patch,AVR]: Fix PR45099
  2011-05-02 16:19 ` Nathan Froyd
@ 2011-05-06 14:07   ` Georg-Johann Lay
  2011-05-10 13:21     ` Denis Chertykov
  0 siblings, 1 reply; 6+ messages in thread
From: Georg-Johann Lay @ 2011-05-06 14:07 UTC (permalink / raw)
  To: Nathan Froyd
  Cc: gcc-patches, Anatoly Sokolov, Denis Chertykov, Eric Weddington

Nathan Froyd schrieb:
> On Mon, May 02, 2011 at 05:23:48PM +0200, Georg-Johann Lay wrote:
>> PR45099 is an extension that gives an error when a fixed register is
>> needed to pass a parameter to a function.
>>
>> Because the program will show malfunction when such code is generated,
>> anyway, I think an error is more appropriate than a warning (as
>> proposed in the PR).
> 
> This seems like something that should be handled by common code.
> 
> -Nathan

Yes, I agree. However, common code it too complicated for me to run
tests for, so I restrict myself to avr backend.

Until such a test will find its way into common code, it might still
be useful in avr backend. I think this has quite low priority for
other targets because global registers are not very common in, e.g. i386.

Johann

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

* Re: [Patch,AVR]: Fix PR45099
  2011-05-06 14:07   ` Georg-Johann Lay
@ 2011-05-10 13:21     ` Denis Chertykov
  2011-05-16 15:53       ` Georg-Johann Lay
  0 siblings, 1 reply; 6+ messages in thread
From: Denis Chertykov @ 2011-05-10 13:21 UTC (permalink / raw)
  To: Georg-Johann Lay
  Cc: Nathan Froyd, gcc-patches, Anatoly Sokolov, Eric Weddington

2011/5/6 Georg-Johann Lay <avr@gjlay.de>:
> Nathan Froyd schrieb:
>> On Mon, May 02, 2011 at 05:23:48PM +0200, Georg-Johann Lay wrote:
>>> PR45099 is an extension that gives an error when a fixed register is
>>> needed to pass a parameter to a function.
>>>
>>> Because the program will show malfunction when such code is generated,
>>> anyway, I think an error is more appropriate than a warning (as
>>> proposed in the PR).
>>
>> This seems like something that should be handled by common code.
>>
>> -Nathan
>
> Yes, I agree. However, common code it too complicated for me to run
> tests for, so I restrict myself to avr backend.
>
> Until such a test will find its way into common code, it might still
> be useful in avr backend. I think this has quite low priority for
> other targets because global registers are not very common in, e.g. i386.
>

I think that better to have this patch.
So, I approve it.
George, please make a working testcase against the trunk and post a
GCC core bug.

Denis.

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

* Re: [Patch,AVR]: Fix PR45099
  2011-05-10 13:21     ` Denis Chertykov
@ 2011-05-16 15:53       ` Georg-Johann Lay
  2011-05-16 17:31         ` Denis Chertykov
  0 siblings, 1 reply; 6+ messages in thread
From: Georg-Johann Lay @ 2011-05-16 15:53 UTC (permalink / raw)
  To: Denis Chertykov
  Cc: Nathan Froyd, gcc-patches, Anatoly Sokolov, Eric Weddington

Denis Chertykov schrieb:
> 2011/5/6 Georg-Johann Lay <avr@gjlay.de>:
>> Nathan Froyd schrieb:
>>> On Mon, May 02, 2011 at 05:23:48PM +0200, Georg-Johann Lay wrote:
>>>> PR45099 is an extension that gives an error when a fixed register is
>>>> needed to pass a parameter to a function.
>>>>
>>>> Because the program will show malfunction when such code is generated,
>>>> anyway, I think an error is more appropriate than a warning (as
>>>> proposed in the PR).
>>> This seems like something that should be handled by common code.
>>>
>>> -Nathan
>> Yes, I agree. However, common code it too complicated for me to run
>> tests for, so I restrict myself to avr backend.
>>
>> Until such a test will find its way into common code, it might still
>> be useful in avr backend. I think this has quite low priority for
>> other targets because global registers are not very common in, e.g. i386.
>>
> 
> I think that better to have this patch.
> So, I approve it.

Ok, applied it as it was:
http://gcc.gnu.org/viewcvs?view=revision&revision=173791

> George, please make a working testcase against the trunk and post a
> GCC core bug.

How should such a testcase look like, and for what target? This is
highly target and ABI dependent. Moreover, the patch above just tests
for argument registers, not return registers.

Basically, I think of someone is hacking with global registers, he
must know what he is doing. There will always be cases where global
regs might violate some things if one is not careful.

Johann

> 
> Denis.
> 

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

* Re: [Patch,AVR]: Fix PR45099
  2011-05-16 15:53       ` Georg-Johann Lay
@ 2011-05-16 17:31         ` Denis Chertykov
  0 siblings, 0 replies; 6+ messages in thread
From: Denis Chertykov @ 2011-05-16 17:31 UTC (permalink / raw)
  To: Georg-Johann Lay
  Cc: Nathan Froyd, gcc-patches, Anatoly Sokolov, Eric Weddington

2011/5/16 Georg-Johann Lay <avr@gjlay.de>:
> Denis Chertykov schrieb:
>> 2011/5/6 Georg-Johann Lay <avr@gjlay.de>:
>>> Nathan Froyd schrieb:
>>>> On Mon, May 02, 2011 at 05:23:48PM +0200, Georg-Johann Lay wrote:
>>>>> PR45099 is an extension that gives an error when a fixed register is
>>>>> needed to pass a parameter to a function.
>>>>>
>>>>> Because the program will show malfunction when such code is generated,
>>>>> anyway, I think an error is more appropriate than a warning (as
>>>>> proposed in the PR).
>>>> This seems like something that should be handled by common code.
>>>>
>>>> -Nathan
>>> Yes, I agree. However, common code it too complicated for me to run
>>> tests for, so I restrict myself to avr backend.
>>>
>>> Until such a test will find its way into common code, it might still
>>> be useful in avr backend. I think this has quite low priority for
>>> other targets because global registers are not very common in, e.g. i386.
>>>
>>
>> I think that better to have this patch.
>> So, I approve it.
>
> Ok, applied it as it was:
> http://gcc.gnu.org/viewcvs?view=revision&revision=173791
>
>> George, please make a working testcase against the trunk and post a
>> GCC core bug.
>
> How should such a testcase look like, and for what target? This is
> highly target and ABI dependent. Moreover, the patch above just tests
> for argument registers, not return registers.
>
> Basically, I think of someone is hacking with global registers, he
> must know what he is doing. There will always be cases where global
> regs might violate some things if one is not careful.

Ok.

Denis.

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

end of thread, other threads:[~2011-05-16 15:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-02 15:24 [Patch,AVR]: Fix PR45099 Georg-Johann Lay
2011-05-02 16:19 ` Nathan Froyd
2011-05-06 14:07   ` Georg-Johann Lay
2011-05-10 13:21     ` Denis Chertykov
2011-05-16 15:53       ` Georg-Johann Lay
2011-05-16 17:31         ` 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).