public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rearnsha at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/45127] Out-of-order execution
Date: Thu, 29 Jul 2010 16:29:00 -0000	[thread overview]
Message-ID: <20100729162922.3391.qmail@sourceware.org> (raw)
In-Reply-To: <bug-45127-19475@http.gcc.gnu.org/bugzilla/>



------- Comment #4 from rearnsha at gcc dot gnu dot org  2010-07-29 16:29 -------
Volatile alone won't prevent re-ordering of non-volatile memory operations. 
The volatile keyword only applies to that particular location (requiring the
compiler not to remove it, or change the number of accesses).

In this case you need to emit a memory barrier to prevent the compiler from
re-arranging the code.

A simple way to do this is to create an empty asm block that clobbers memory,
for example:

   asm  ("" : : : "memory");

this will cause the compiler to force out all pending memory operations before
the barrier and not to move later operations earlier.


-- 

rearnsha at gcc dot gnu dot org changed:

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


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


  parent reply	other threads:[~2010-07-29 16:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-29 13:10 [Bug c/45127] New: " aleksazr at gmail dot com
2010-07-29 13:13 ` [Bug c/45127] " aleksazr at gmail dot com
2010-07-29 13:30 ` rguenth at gcc dot gnu dot org
2010-07-29 14:56 ` [Bug target/45127] " aleksazr at gmail dot com
2010-07-29 16:29 ` rearnsha at gcc dot gnu dot org [this message]
2010-07-29 19:19 ` aleksazr at gmail dot com
2010-07-30 13:56 ` aleksazr at gmail dot com
2010-07-30 14:00 ` aleksazr at gmail dot com

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=20100729162922.3391.qmail@sourceware.org \
    --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).