public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/46192] New: renaming of a volatile variable generates wrong code
@ 2010-10-26 22:32 rolf.ebert.gcc at gmx dot de
  2010-10-26 22:40 ` [Bug ada/46192] " rolf.ebert.gcc at gmx dot de
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: rolf.ebert.gcc at gmx dot de @ 2010-10-26 22:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192

           Summary: renaming of a volatile variable generates wrong code
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: rolf.ebert.gcc@gmx.de
            Target: avr


The following Ada code is translated to wrong assembler when using the renamed
variable.

with Interfaces;  use Interfaces;
package Renaming is

   procedure Put_Raw;

end Renaming;

with System;    use System;

package body Renaming is

   type Bit_Number is new Unsigned_8 range 0 .. 7;

   --  Give access to every single bit in a byte as a boolean.
   type Bits_In_Byte is array (Bit_Number) of Boolean;
   pragma Pack (Bits_In_Byte);
   for Bits_In_Byte'Size use 8;

   --  USART Control and Status Register A
   UCSR0A_Addr    : constant Address    := System'To_Address(16#c0#);
   UCSR0A_Bits    : Bits_In_Byte;
   for UCSR0A_Bits'Address use UCSR0A_Addr;
   pragma Volatile (UCSR0A_Bits);

   UCSRA_Bits : Bits_In_Byte renames UCSR0A_Bits;

   procedure Put_Raw is
   begin
      -- wait until Data Register Empty (DRE) is signaled
      while UCSRA_Bits (5) = False loop null; end loop;
   end Put_Raw;

end Renaming;

$ avr-gcc -S -mmcu=atmega328p -Os renaming.adb

.global renaming__put_raw
        .type   renaming__put_raw, @function
renaming__put_raw:
/* prologue: function */
/* frame size = 0 */
/* stack size = 0 */
.L__stack_usage = 0
        lds r24,192
        sbrs r24,5
.L5:
        rjmp .L5
.L4:
        ret
        .size   renaming__put_raw, .-renaming__put_raw

See the placement of the label .L5

If you don't use the renamed variable but directly UCSR0A_Bits as in 
      while UCSR0A_Bits (5) = False loop null; end loop;
you get correct assembler code:

.global renaming__put_raw
        .type   renaming__put_raw, @function
renaming__put_raw:
/* prologue: function */
/* frame size = 0 */
/* stack size = 0 */
.L__stack_usage = 0
.L3:
        lds r24,192
        sbrs r24,5
        rjmp .L3
/* epilogue start */
        ret
        .size   renaming__put_raw, .-renaming__put_raw


Rolf


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

* [Bug ada/46192] renaming of a volatile variable generates wrong code
  2010-10-26 22:32 [Bug ada/46192] New: renaming of a volatile variable generates wrong code rolf.ebert.gcc at gmx dot de
@ 2010-10-26 22:40 ` rolf.ebert.gcc at gmx dot de
  2011-02-11 18:14 ` simon at pushface dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rolf.ebert.gcc at gmx dot de @ 2010-10-26 22:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192

--- Comment #1 from Rolf Ebert <rolf.ebert.gcc at gmx dot de> 2010-10-26 22:40:50 UTC ---
It might be related to PR37599


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

* [Bug ada/46192] renaming of a volatile variable generates wrong code
  2010-10-26 22:32 [Bug ada/46192] New: renaming of a volatile variable generates wrong code rolf.ebert.gcc at gmx dot de
  2010-10-26 22:40 ` [Bug ada/46192] " rolf.ebert.gcc at gmx dot de
@ 2011-02-11 18:14 ` simon at pushface dot org
  2011-02-11 18:20 ` simon at pushface dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: simon at pushface dot org @ 2011-02-11 18:14 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192

simon at pushface dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simon at pushface dot org

--- Comment #2 from simon at pushface dot org 2011-02-11 18:10:06 UTC ---
Still present in gcc version 4.6.0 20110203 (experimental) [trunk revision
157963] for x86_64-apple-darwin10. Generated assembler is

_renaming__put_raw:
LFB3:
        movzbl  192, %eax
        andl    $32, %eax
        .align 4,0x90
L3:
        testb   %al, %al
        je      L3
        ret


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

* [Bug ada/46192] renaming of a volatile variable generates wrong code
  2010-10-26 22:32 [Bug ada/46192] New: renaming of a volatile variable generates wrong code rolf.ebert.gcc at gmx dot de
  2010-10-26 22:40 ` [Bug ada/46192] " rolf.ebert.gcc at gmx dot de
  2011-02-11 18:14 ` simon at pushface dot org
@ 2011-02-11 18:20 ` simon at pushface dot org
  2012-01-16 22:18 ` rolf.ebert.gcc at gmx dot de
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: simon at pushface dot org @ 2011-02-11 18:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192

--- Comment #3 from simon at pushface dot org 2011-02-11 18:18:26 UTC ---
(In reply to comment #2)
> Still present in gcc version 4.6.0 20110203 (experimental) [trunk revision
> 157963] for x86_64-apple-darwin10. Generated assembler is
> 
> _renaming__put_raw:
> LFB3:
>         movzbl  192, %eax
>         andl    $32, %eax
>         .align 4,0x90
> L3:
>         testb   %al, %al
>         je      L3
>         ret

That was at -O2. The code for -O1 is OK:

_renaming__put_raw:
LFB3:
L3:
        testb   $32, 192
        je      L3
        ret


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

* [Bug ada/46192] renaming of a volatile variable generates wrong code
  2010-10-26 22:32 [Bug ada/46192] New: renaming of a volatile variable generates wrong code rolf.ebert.gcc at gmx dot de
                   ` (2 preceding siblings ...)
  2011-02-11 18:20 ` simon at pushface dot org
@ 2012-01-16 22:18 ` rolf.ebert.gcc at gmx dot de
  2012-01-20 16:09 ` [Bug ada/46192] [4.5/4.6/4.7 regression] wrong code for renaming of packed array with address clause ebotcazou at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rolf.ebert.gcc at gmx dot de @ 2012-01-16 22:18 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192

--- Comment #4 from Rolf Ebert <rolf.ebert.gcc at gmx dot de> 2012-01-16 22:04:39 UTC ---
The problem is still present in gcc-4.7 snapshot as of 2012-01-14 (tested on
Linux Debian)


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

* [Bug ada/46192] [4.5/4.6/4.7 regression] wrong code for renaming of packed array with address clause
  2010-10-26 22:32 [Bug ada/46192] New: renaming of a volatile variable generates wrong code rolf.ebert.gcc at gmx dot de
                   ` (3 preceding siblings ...)
  2012-01-16 22:18 ` rolf.ebert.gcc at gmx dot de
@ 2012-01-20 16:09 ` ebotcazou at gcc dot gnu.org
  2012-01-20 16:24 ` ebotcazou at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-01-20 16:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|avr                         |
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-01-20
                 CC|                            |ebotcazou at gcc dot
                   |                            |gnu.org
   Target Milestone|---                         |4.5.4
            Summary|renaming of a volatile      |[4.5/4.6/4.7 regression]
                   |variable generates wrong    |wrong code for renaming of
                   |code                        |packed array with address
                   |                            |clause
     Ever Confirmed|0                           |1

--- Comment #5 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-01-20 15:50:30 UTC ---
This looks more related to the address clause on the packed array though.


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

* [Bug ada/46192] [4.5/4.6/4.7 regression] wrong code for renaming of packed array with address clause
  2010-10-26 22:32 [Bug ada/46192] New: renaming of a volatile variable generates wrong code rolf.ebert.gcc at gmx dot de
                   ` (4 preceding siblings ...)
  2012-01-20 16:09 ` [Bug ada/46192] [4.5/4.6/4.7 regression] wrong code for renaming of packed array with address clause ebotcazou at gcc dot gnu.org
@ 2012-01-20 16:24 ` ebotcazou at gcc dot gnu.org
  2012-01-20 21:00 ` [Bug ada/46192] [4.5/4.6/4.7 regression] wrong code for renaming of volatile " jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-01-20 16:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |ebotcazou at gcc dot
                   |gnu.org                     |gnu.org

--- Comment #6 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-01-20 15:52:34 UTC ---
Investigating.


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

* [Bug ada/46192] [4.5/4.6/4.7 regression] wrong code for renaming of volatile packed array with address clause
  2010-10-26 22:32 [Bug ada/46192] New: renaming of a volatile variable generates wrong code rolf.ebert.gcc at gmx dot de
                   ` (5 preceding siblings ...)
  2012-01-20 16:24 ` ebotcazou at gcc dot gnu.org
@ 2012-01-20 21:00 ` jakub at gcc dot gnu.org
  2012-01-21 15:07 ` ebotcazou at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-01-20 21:00 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |jakub at gcc dot gnu.org


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

* [Bug ada/46192] [4.5/4.6/4.7 regression] wrong code for renaming of volatile packed array with address clause
  2010-10-26 22:32 [Bug ada/46192] New: renaming of a volatile variable generates wrong code rolf.ebert.gcc at gmx dot de
                   ` (6 preceding siblings ...)
  2012-01-20 21:00 ` [Bug ada/46192] [4.5/4.6/4.7 regression] wrong code for renaming of volatile " jakub at gcc dot gnu.org
@ 2012-01-21 15:07 ` ebotcazou at gcc dot gnu.org
  2012-01-21 15:12 ` ebotcazou at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-01-21 15:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192

--- Comment #7 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-01-21 14:58:39 UTC ---
Author: ebotcazou
Date: Sat Jan 21 14:58:33 2012
New Revision: 183365

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183365
Log:
    PR ada/46192
    * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: In the case of a
    renaming, preserve the volatileness through the indirection, if any.

Added:
    trunk/gcc/testsuite/gnat.dg/renaming5.adb
    trunk/gcc/testsuite/gnat.dg/renaming5.ads
Modified:
    trunk/gcc/ada/ChangeLog
    trunk/gcc/ada/gcc-interface/decl.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug ada/46192] [4.5/4.6/4.7 regression] wrong code for renaming of volatile packed array with address clause
  2010-10-26 22:32 [Bug ada/46192] New: renaming of a volatile variable generates wrong code rolf.ebert.gcc at gmx dot de
                   ` (7 preceding siblings ...)
  2012-01-21 15:07 ` ebotcazou at gcc dot gnu.org
@ 2012-01-21 15:12 ` ebotcazou at gcc dot gnu.org
  2012-01-21 15:25 ` ebotcazou at gcc dot gnu.org
  2012-01-21 15:25 ` ebotcazou at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-01-21 15:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192

--- Comment #8 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-01-21 15:01:56 UTC ---
Author: ebotcazou
Date: Sat Jan 21 15:01:48 2012
New Revision: 183366

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183366
Log:
    PR ada/46192
    * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: In the case of a
    renaming, preserve the volatileness through the indirection, if any.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gnat.dg/renaming5.adb
      - copied unchanged from r183365,
trunk/gcc/testsuite/gnat.dg/renaming5.adb
    branches/gcc-4_6-branch/gcc/testsuite/gnat.dg/renaming5.ads
      - copied unchanged from r183365,
trunk/gcc/testsuite/gnat.dg/renaming5.ads
Modified:
    branches/gcc-4_6-branch/gcc/ada/ChangeLog
    branches/gcc-4_6-branch/gcc/ada/gcc-interface/decl.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug ada/46192] [4.5/4.6/4.7 regression] wrong code for renaming of volatile packed array with address clause
  2010-10-26 22:32 [Bug ada/46192] New: renaming of a volatile variable generates wrong code rolf.ebert.gcc at gmx dot de
                   ` (8 preceding siblings ...)
  2012-01-21 15:12 ` ebotcazou at gcc dot gnu.org
@ 2012-01-21 15:25 ` ebotcazou at gcc dot gnu.org
  2012-01-21 15:25 ` ebotcazou at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-01-21 15:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192

--- Comment #9 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-01-21 15:04:31 UTC ---
Author: ebotcazou
Date: Sat Jan 21 15:04:25 2012
New Revision: 183367

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183367
Log:
    PR ada/46192
    * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: In the case of a
    renaming, preserve the volatileness through the indirection, if any.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gnat.dg/renaming5.adb
      - copied unchanged from r183365,
trunk/gcc/testsuite/gnat.dg/renaming5.adb
    branches/gcc-4_5-branch/gcc/testsuite/gnat.dg/renaming5.ads
      - copied unchanged from r183366,
trunk/gcc/testsuite/gnat.dg/renaming5.ads
Modified:
    branches/gcc-4_5-branch/gcc/ada/ChangeLog
    branches/gcc-4_5-branch/gcc/ada/gcc-interface/decl.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


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

* [Bug ada/46192] [4.5/4.6/4.7 regression] wrong code for renaming of volatile packed array with address clause
  2010-10-26 22:32 [Bug ada/46192] New: renaming of a volatile variable generates wrong code rolf.ebert.gcc at gmx dot de
                   ` (9 preceding siblings ...)
  2012-01-21 15:25 ` ebotcazou at gcc dot gnu.org
@ 2012-01-21 15:25 ` ebotcazou at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-01-21 15:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|ebotcazou at gcc dot        |
                   |gnu.org                     |
         Resolution|                            |FIXED

--- Comment #10 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-01-21 15:06:58 UTC ---
In the next 4.5.x and above releases.


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

end of thread, other threads:[~2012-01-21 15:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-26 22:32 [Bug ada/46192] New: renaming of a volatile variable generates wrong code rolf.ebert.gcc at gmx dot de
2010-10-26 22:40 ` [Bug ada/46192] " rolf.ebert.gcc at gmx dot de
2011-02-11 18:14 ` simon at pushface dot org
2011-02-11 18:20 ` simon at pushface dot org
2012-01-16 22:18 ` rolf.ebert.gcc at gmx dot de
2012-01-20 16:09 ` [Bug ada/46192] [4.5/4.6/4.7 regression] wrong code for renaming of packed array with address clause ebotcazou at gcc dot gnu.org
2012-01-20 16:24 ` ebotcazou at gcc dot gnu.org
2012-01-20 21:00 ` [Bug ada/46192] [4.5/4.6/4.7 regression] wrong code for renaming of volatile " jakub at gcc dot gnu.org
2012-01-21 15:07 ` ebotcazou at gcc dot gnu.org
2012-01-21 15:12 ` ebotcazou at gcc dot gnu.org
2012-01-21 15:25 ` ebotcazou at gcc dot gnu.org
2012-01-21 15:25 ` ebotcazou at gcc dot gnu.org

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).