public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "takeo dot komiyama at freescale dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/18735] New: option -fvolatile-global will not effect in some case
Date: Tue, 30 Nov 2004 09:28:00 -0000	[thread overview]
Message-ID: <20041130092823.18735.takeo.komiyama@freescale.com> (raw)

With above code

------------ code --------------------------------------------
int glob_a = 3;

int main () 
{
  volatile int a;

  glob_a = 1;

  if ( 1 == glob_a )  // Cause problem here
  { }                 // Empty if

  return 0;
}
---------------------------------------------------
When compiled with 

gcc  -fvolatile-global -S -o main.s

To treat glob_a as "volatile", but as a result, it show following 
assembly code
------- test section of assembly code -----------------------
00000000 <main>:
main():
/proj/sve/working/komiyama/cpp_test/volatile_test1/main.cc:5
   0:   94 21 ff e0     stwu    r1,-32(r1)
   4:   7c 08 02 a6     mflr    r0
   8:   93 e1 00 1c     stw     r31,28(r1)
   c:   90 01 00 24     stw     r0,36(r1)
  10:   7c 3f 0b 78     mr      r31,r1
  14:   48 00 00 01     bl      14 <main+0x14>
                        14: R_PPC_REL24 __eabi
/proj/sve/working/komiyama/cpp_test/volatile_test1/main.cc:8
  18:   3d 20 00 00     lis     r9,0
                        1a: R_PPC_ADDR16_HA     glob_a
  1c:   38 00 00 01     li      r0,1
  20:   90 09 00 00     stw     r0,0(r9)
                        22: R_PPC_ADDR16_LO     glob_a
/proj/sve/working/komiyama/cpp_test/volatile_test1/main.cc:13
  24:   38 00 00 00     li      r0,0
/proj/sve/working/komiyama/cpp_test/volatile_test1/main.cc:14
  28:   7c 03 03 78     mr      r3,r0
  2c:   81 61 00 00     lwz     r11,0(r1)
  30:   80 0b 00 04     lwz     r0,4(r11)
  34:   7c 08 03 a6     mtlr    r0
  38:   83 eb ff fc     lwz     r31,-4(r11)
  3c:   7d 61 5b 78     mr      r1,r11
  40:   4e 80 00 20     blr
-------------------------------------------------------------
It seems 

if ( 1 == glob_a )
    { }

is gone somewhere, When I set 

volatile int glob_a = 3;

gcc compile to 
-------- assembly code when set glob_a as volatile ------
00000000 <main>:
main():
/proj/sve/working/komiyama/cpp_test/volatile_test1/main.cc:5
   0:   94 21 ff e0     stwu    r1,-32(r1)
   4:   7c 08 02 a6     mflr    r0
   8:   93 e1 00 1c     stw     r31,28(r1)
   c:   90 01 00 24     stw     r0,36(r1)
  10:   7c 3f 0b 78     mr      r31,r1
  14:   48 00 00 01     bl      14 <main+0x14>
                        14: R_PPC_REL24 __eabi
/proj/sve/working/komiyama/cpp_test/volatile_test1/main.cc:8
  18:   3d 20 00 00     lis     r9,0
                        1a: R_PPC_ADDR16_HA     glob_a
  1c:   38 00 00 01     li      r0,1
  20:   90 09 00 00     stw     r0,0(r9)
                        22: R_PPC_ADDR16_LO     glob_a
/proj/sve/working/komiyama/cpp_test/volatile_test1/main.cc:10
  24:   3d 20 00 00     lis     r9,0
                        26: R_PPC_ADDR16_HA     glob_a
  28:   80 09 00 00     lwz     r0,0(r9)
                        2a: R_PPC_ADDR16_LO     glob_a
/proj/sve/working/komiyama/cpp_test/volatile_test1/main.cc:13
  2c:   38 00 00 00     li      r0,0
/proj/sve/working/komiyama/cpp_test/volatile_test1/main.cc:14
  30:   7c 03 03 78     mr      r3,r0
  34:   81 61 00 00     lwz     r11,0(r1)
  38:   80 0b 00 04     lwz     r0,4(r11)
  3c:   7c 08 03 a6     mtlr    r0
  40:   83 eb ff fc     lwz     r31,-4(r11)
  44:   7d 61 5b 78     mr      r1,r11
  48:   4e 80 00 20     blr
------------------------------------------------------------------

Envionment
 O.S : Linux ( kernel 2.4.20-30.7.legacy)
       Glibc  2.2.5

 GCC : 3.3.3 configured with cross compiler
        ( Host is linux, target is ppc-unkown-eabi)

       with 
         binutils ... 2.14
         newlib   ... 1.12

-- 
           Summary: option -fvolatile-global will not effect in some case
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: takeo dot komiyama at freescale dot com
                CC: gcc-bugs at gcc dot gnu dot org,takeo dot komiyama at
                    freescale dot com


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


             reply	other threads:[~2004-11-30  9:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-30  9:28 takeo dot komiyama at freescale dot com [this message]
2004-11-30 12:36 ` [Bug c/18735] " pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041130092823.18735.takeo.komiyama@freescale.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).