public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Anders Blomdell <andersb@localhost.localdomain>
To: gcc-gnats@gcc.gnu.org
Subject: optimization/6059: -fvolatile-global and -fvolatile-static fails to set volatile
Date: Tue, 26 Mar 2002 02:46:00 -0000	[thread overview]
Message-ID: <200203261038.g2QAcn101746@localhost.localdomain> (raw)


>Number:         6059
>Category:       optimization
>Synopsis:       -fvolatile-* doesn't mark variables as volatile
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 26 02:46:10 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Anders Blomdell <anders.blomdell@control.lth.se>
>Release:        3.0.4
>Organization:
Department of Automatic Control
>Environment:
System: Linux aljazari 2.4.13-KURT #2 Thu Nov 8 10:49:33 CET 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: m68k-unknown-elf
configured with: ../../../gcc-3.0.4/configure --prefix=/usr/local/packages/cross/m68k-elf --target=m68k-elf --with-newlib : (reconfigured) ../../../gcc-3.0.4/configure --prefix=/usr/local/packages/cross/m68k-elf --target=m68k-elf --with-newlib : (reconfigured) ../../../gcc-3.0.4/configure --with-gcc-version-trigger=/work/aljazari2/andersb/gnu/gcc-3.0.4/gcc/version.c --host=i686-pc-linux-gnu --prefix=/usr/local/packages/cross/m68k-elf --target=m68k-elf --with-newlib --enable-checking=misc,tree,rtl,gc,gcac
>Description:
	-fvolatile-* doesn't have the same effect as declaring a variable as volatile.
>How-To-Repeat:
Compile this small C program with -O*,  where f and g should produce identical code when -fvolatile-* is specified.

  static int gi;
  static volatile int vgi;

  void f() {
    int i;
    for (i = 0 ; i < 1000 ; i++) { gi++; }
  }

  void vf() {
    int i;
    for (i = 0 ; i < 1000 ; i++) { vgi++; }
  }

>Fix:
Apply this patch:

--- varasm.c~   Sat Sep 22 03:33:20 2001
+++ varasm.c    Tue Mar 26 11:26:25 2002
@@ -743,7 +743,10 @@
        && TREE_PUBLIC (decl))
       || ((flag_volatile_static && TREE_CODE (decl) == VAR_DECL
           && (TREE_PUBLIC (decl) || TREE_STATIC (decl)))))
-    TREE_SIDE_EFFECTS (decl) = 1;
+    {
+      TREE_SIDE_EFFECTS (decl) = 1; 
+      TREE_THIS_VOLATILE(decl) = 1;
+    }
 
   SET_DECL_RTL (decl, gen_rtx_MEM (DECL_MODE (decl),
                                   gen_rtx_SYMBOL_REF (Pmode, name)));

>Release-Note:
>Audit-Trail:
>Unformatted:


                 reply	other threads:[~2002-03-26 10:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200203261038.g2QAcn101746@localhost.localdomain \
    --to=andersb@localhost.localdomain \
    --cc=gcc-gnats@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).