public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeffrey Walton <noloader@gmail.com>
To: Andrew Haley <aph@redhat.com>
Cc: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: Re: Disable optimizations on one function (was: 'pragma optimize' ...)
Date: Thu, 16 Jul 2015 09:40:00 -0000	[thread overview]
Message-ID: <CAH8yC8nh0KreX37vExaXY-dNTM0_FZGHCno8oL+DU+7P-cwXwA@mail.gmail.com> (raw)
In-Reply-To: <55A7729F.2090604@redhat.com>

>> Many folks try and cast ptr to volatile, but that's an abuse because
>> GCC considers volatile something for memory mapped hardware. Volatile
>> should not be used in an attempt to tame the optimizer.
>
> GCC does not consider volatile to be something for memory mapped
> hardware.

OK, this appears to be creating a moving definition (or the definition
has changed since I took note of it). I took the last definition from
Ian Lance Taylor. See http://www.airs.com/blog/archives/154 and, for
example, https://gcc.gnu.org/ml/gcc-help/2012-03/msg00257.html.

> ...
> If you don't mind being nonportable, a memoryclobber should do it:
>
>     memset(ptr, 0x00, n);
>     asm volatile("": : : "memory");
>
> or even:
>
>     memset(ptr, 0x00, n);
>     __atomic_thread_fence(__ATOMIC_RELAXED);

Perfect, thanks.

Jeff

  reply	other threads:[~2015-07-16  9:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16  5:58 Jeffrey Walton
2015-07-16  9:00 ` Andrew Haley
2015-07-16  9:40   ` Jeffrey Walton [this message]
2015-07-16  9:59     ` Andrew Haley
2015-07-16 10:05       ` Jeffrey Walton
2015-07-16 16:32 ` Martin Sebor

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=CAH8yC8nh0KreX37vExaXY-dNTM0_FZGHCno8oL+DU+7P-cwXwA@mail.gmail.com \
    --to=noloader@gmail.com \
    --cc=aph@redhat.com \
    --cc=gcc-help@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).