public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/31072]  New: Wrong code for volatile var with initalization and optimization
@ 2007-03-07 15:38 a_fisch at gmx dot de
  2007-03-07 15:41 ` [Bug c/31072] " a_fisch at gmx dot de
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: a_fisch at gmx dot de @ 2007-03-07 15:38 UTC (permalink / raw)
  To: gcc-bugs

I tracked it down to the following code, which is not compiled as expected, if
optimization (> O1) is turned on. 

Contents of fg.c:
---8<------8<---------8<---
extern volatile int ReadyFlag_NotProperlyInitialized;

volatile int ReadyFlag_NotProperlyInitialized=1;
volatile int ReadyFlag_InitializationOk=1;
---8<------8<---------8<---

My command line for GCC 4.3-20070223:
  powerpc-elf-gcc -O1 -S -o fg_O1.s fg.i  


In the generated assembler output, the variable ReadyFlag_InitializationOk is
placed in section .sbss (instead of .sdata) an is initialized with 0 instead of
1. 
ReadyFlag_InitializationOk is initialized as expected. The only difference is
the extern declaration for ReadyFlag_NotProperlyInitialized.

Contents of fg_O1.s:
---8<------8<---------8<---
        .file   "fg.c"
        .globl ReadyFlag_NotProperlyInitialized
        .globl ReadyFlag_InitializationOk
        .section        .sbss,"aw",@nobits
        .align 2
        .type   ReadyFlag_NotProperlyInitialized, @object
        .size   ReadyFlag_NotProperlyInitialized, 4
ReadyFlag_NotProperlyInitialized:
        .zero   4
        .section        .sdata,"aw",@progbits
        .align 2
        .type   ReadyFlag_InitializationOk, @object
        .size   ReadyFlag_InitializationOk, 4
ReadyFlag_InitializationOk:
        .long   1
        .ident  "GCC: (GNU) 4.3.0 20070223 (experimental)"
---8<------8<---------8<---

gcc-3.4.6 built with the same system (same build, host and target) is ok!
gcc-4.1.2 built with the same system (same build, host and target) is ok!

gcc-4.2-20070221 shows the same error as 4.3-20070223 (both built as above)


-- 
           Summary: Wrong code for volatile var with initalization and
                    optimization
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: a_fisch at gmx dot de
 GCC build triplet: mingw32
  GCC host triplet: mingw32
GCC target triplet: powerpc-elf


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


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

* [Bug c/31072] Wrong code for volatile var with initalization and optimization
  2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
@ 2007-03-07 15:41 ` a_fisch at gmx dot de
  2007-03-07 15:44 ` a_fisch at gmx dot de
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: a_fisch at gmx dot de @ 2007-03-07 15:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from a_fisch at gmx dot de  2007-03-07 15:41 -------
Created an attachment (id=13162)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13162&action=view)
Preprocessed source of code sample 


-- 


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


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

* [Bug c/31072] Wrong code for volatile var with initalization and optimization
  2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
  2007-03-07 15:41 ` [Bug c/31072] " a_fisch at gmx dot de
@ 2007-03-07 15:44 ` a_fisch at gmx dot de
  2007-03-07 17:11 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: a_fisch at gmx dot de @ 2007-03-07 15:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from a_fisch at gmx dot de  2007-03-07 15:44 -------
Created an attachment (id=13163)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13163&action=view)
Generated assembler output: powerpc-elf-gcc -O1 -S -o fg_O1.s fg.i


-- 


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


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

* [Bug c/31072] Wrong code for volatile var with initalization and optimization
  2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
  2007-03-07 15:41 ` [Bug c/31072] " a_fisch at gmx dot de
  2007-03-07 15:44 ` a_fisch at gmx dot de
@ 2007-03-07 17:11 ` pinskia at gcc dot gnu dot org
  2007-03-07 17:44 ` a_fisch at gmx dot de
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-07 17:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2007-03-07 17:11 -------
.sbss is .sdata but in the bss part of it.
If your loader does not zero bss, then you can use -fno-zero-initialized-in-bss
to get the variable not stored in the bss section.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c/31072] Wrong code for volatile var with initalization and optimization
  2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
                   ` (2 preceding siblings ...)
  2007-03-07 17:11 ` pinskia at gcc dot gnu dot org
@ 2007-03-07 17:44 ` a_fisch at gmx dot de
  2007-03-07 22:33 ` [Bug target/31072] [4.3 Rgression] " pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: a_fisch at gmx dot de @ 2007-03-07 17:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from a_fisch at gmx dot de  2007-03-07 17:43 -------
Subject: Re:  Wrong code for volatile var with initalization
        and optimization

My runtime environment is clearing .bss but the problem is that the
initialization value is != 0 . Because of the value != 0 it's not
allowed to be placed in the bss part of sdata.

And I'm requesting to reopen 31072 again. 


-- 


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


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

* [Bug target/31072] [4.3 Rgression] Wrong code for volatile var with initalization and optimization
  2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
                   ` (3 preceding siblings ...)
  2007-03-07 17:44 ` a_fisch at gmx dot de
@ 2007-03-07 22:33 ` pinskia at gcc dot gnu dot org
  2007-03-07 22:34 ` [Bug target/31072] [4.2/4.3 " pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-07 22:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2007-03-07 22:33 -------
Woops.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
          Component|c                           |target
  GCC build triplet|mingw32                     |
   GCC host triplet|mingw32                     |
 GCC target triplet|powerpc-elf                 |powerpc-linux-gnu, powerpc-
                   |                            |elf
         Resolution|INVALID                     |
            Summary|Wrong code for volatile var |[4.3 Rgression] Wrong code
                   |with initalization and      |for volatile var with
                   |optimization                |initalization and
                   |                            |optimization
            Version|4.2.0                       |4.3.0


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


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

* [Bug target/31072] [4.2/4.3 Rgression] Wrong code for volatile var with initalization and optimization
  2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
                   ` (4 preceding siblings ...)
  2007-03-07 22:33 ` [Bug target/31072] [4.3 Rgression] " pinskia at gcc dot gnu dot org
@ 2007-03-07 22:34 ` pinskia at gcc dot gnu dot org
  2007-03-08  3:41 ` [Bug c/31072] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-07 22:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2007-03-07 22:34 -------
I was looking at the bug wrong the first time.
Anyways this is caused by section anchors.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
           Severity|normal                      |blocker
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2007-03-07 22:34:33
               date|                            |
            Summary|[4.3 Rgression] Wrong code  |[4.2/4.3 Rgression] Wrong
                   |for volatile var with       |code for volatile var with
                   |initalization and           |initalization and
                   |optimization                |optimization
   Target Milestone|---                         |4.2.0


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


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

* [Bug c/31072] [4.2/4.3 Rgression] Wrong code for volatile var with initalization and optimization
  2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
                   ` (5 preceding siblings ...)
  2007-03-07 22:34 ` [Bug target/31072] [4.2/4.3 " pinskia at gcc dot gnu dot org
@ 2007-03-08  3:41 ` pinskia at gcc dot gnu dot org
  2007-03-08 19:15 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-08  3:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2007-03-08 03:41 -------
I have a very simple fix to the C front-end that I am testing.  The C front-end
causes the DECL_RTL to be created early on.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
          Component|target                      |c


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


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

* [Bug c/31072] [4.2/4.3 Rgression] Wrong code for volatile var with initalization and optimization
  2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
                   ` (6 preceding siblings ...)
  2007-03-08  3:41 ` [Bug c/31072] " pinskia at gcc dot gnu dot org
@ 2007-03-08 19:15 ` pinskia at gcc dot gnu dot org
  2007-03-09  0:32 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-08 19:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2007-03-08 19:15 -------
Here is the patch which I am testing:
Index: c-decl.c
===================================================================
--- c-decl.c    (revision 1532)
+++ c-decl.c    (working copy)
@@ -1650,11 +1650,7 @@ merge_decls (tree newdecl, tree olddecl,
     TREE_READONLY (olddecl) = 1;

   if (TREE_THIS_VOLATILE (newdecl))
-    {
-      TREE_THIS_VOLATILE (olddecl) = 1;
-      if (TREE_CODE (newdecl) == VAR_DECL)
-       make_var_volatile (newdecl);
-    }
+    TREE_THIS_VOLATILE (olddecl) = 1;

   /* Merge deprecatedness.  */
   if (TREE_DEPRECATED (newdecl))


-- 


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


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

* [Bug c/31072] [4.2/4.3 Rgression] Wrong code for volatile var with initalization and optimization
  2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
                   ` (7 preceding siblings ...)
  2007-03-08 19:15 ` pinskia at gcc dot gnu dot org
@ 2007-03-09  0:32 ` pinskia at gcc dot gnu dot org
  2007-03-09  0:33 ` [Bug c/31072] [4.2 " pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-09  0:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pinskia at gcc dot gnu dot org  2007-03-09 00:32 -------
Subject: Bug 31072

Author: pinskia
Date: Fri Mar  9 00:32:34 2007
New Revision: 122736

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122736
Log:
2007-03-08  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR C/31072
        * c-decl.c (merge_decls): Don't call make_var_volatile.
        * varasm.c (make_var_volatile): Remove.
        * output.h (make_var_volatile): Remove.

2007-03-08  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR C/31072
        * gcc.c-torture/execute/pr31072.c: New test.



Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr31072.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-decl.c
    trunk/gcc/output.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/varasm.c


-- 


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


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

* [Bug c/31072] [4.2 Rgression] Wrong code for volatile var with initalization and optimization
  2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
                   ` (8 preceding siblings ...)
  2007-03-09  0:32 ` pinskia at gcc dot gnu dot org
@ 2007-03-09  0:33 ` pinskia at gcc dot gnu dot org
  2007-03-09  2:50 ` pinskia at gcc dot gnu dot org
  2007-03-09  2:50 ` pinskia at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-09  0:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from pinskia at gcc dot gnu dot org  2007-03-09 00:32 -------
Fixed on the mainline.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.2/4.3 Rgression] Wrong   |[4.2 Rgression] Wrong code
                   |code for volatile var with  |for volatile var with
                   |initalization and           |initalization and
                   |optimization                |optimization


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


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

* [Bug c/31072] [4.2 Rgression] Wrong code for volatile var with initalization and optimization
  2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
                   ` (9 preceding siblings ...)
  2007-03-09  0:33 ` [Bug c/31072] [4.2 " pinskia at gcc dot gnu dot org
@ 2007-03-09  2:50 ` pinskia at gcc dot gnu dot org
  2007-03-09  2:50 ` pinskia at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-09  2:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from pinskia at gcc dot gnu dot org  2007-03-09 02:50 -------
Subject: Bug 31072

Author: pinskia
Date: Fri Mar  9 02:50:22 2007
New Revision: 122739

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122739
Log:
2007-03-08  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR C/31072
        * c-decl.c (merge_decls): Don't call make_var_volatile.
        * varasm.c (make_var_volatile): Remove.
        * output.h (make_var_volatile): Remove.
2007-03-08  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR C/31072
        * gcc.c-torture/execute/pr31072.c: New test.



Added:
    branches/gcc-4_2-branch/gcc/testsuite/gcc.c-torture/execute/pr31072.c
      - copied unchanged from r122736,
trunk/gcc/testsuite/gcc.c-torture/execute/pr31072.c
Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/c-decl.c
    branches/gcc-4_2-branch/gcc/output.h
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_2-branch/gcc/varasm.c


-- 


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


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

* [Bug c/31072] [4.2 Rgression] Wrong code for volatile var with initalization and optimization
  2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
                   ` (10 preceding siblings ...)
  2007-03-09  2:50 ` pinskia at gcc dot gnu dot org
@ 2007-03-09  2:50 ` pinskia at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-09  2:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from pinskia at gcc dot gnu dot org  2007-03-09 02:50 -------
Fixed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2007-03-09  2:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-07 15:38 [Bug c/31072] New: Wrong code for volatile var with initalization and optimization a_fisch at gmx dot de
2007-03-07 15:41 ` [Bug c/31072] " a_fisch at gmx dot de
2007-03-07 15:44 ` a_fisch at gmx dot de
2007-03-07 17:11 ` pinskia at gcc dot gnu dot org
2007-03-07 17:44 ` a_fisch at gmx dot de
2007-03-07 22:33 ` [Bug target/31072] [4.3 Rgression] " pinskia at gcc dot gnu dot org
2007-03-07 22:34 ` [Bug target/31072] [4.2/4.3 " pinskia at gcc dot gnu dot org
2007-03-08  3:41 ` [Bug c/31072] " pinskia at gcc dot gnu dot org
2007-03-08 19:15 ` pinskia at gcc dot gnu dot org
2007-03-09  0:32 ` pinskia at gcc dot gnu dot org
2007-03-09  0:33 ` [Bug c/31072] [4.2 " pinskia at gcc dot gnu dot org
2007-03-09  2:50 ` pinskia at gcc dot gnu dot org
2007-03-09  2:50 ` pinskia at gcc dot gnu dot 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).