This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Disable optimizations on one function (was: 'pragma optimize' ...)
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Thu, 16 Jul 2015 06:05:16 -0400
- Subject: Re: Disable optimizations on one function (was: 'pragma optimize' ...)
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8kU9JXSyFHrW9neztA4btnjXuxv+m3KyPWp84F=Y1Rv7A at mail dot gmail dot com> <55A7729F dot 2090604 at redhat dot com> <CAH8yC8nh0KreX37vExaXY-dNTM0_FZGHCno8oL+DU+7P-cwXwA at mail dot gmail dot com> <55A78068 dot 4020201 at redhat dot com>
- Reply-to: noloader at gmail dot com
On Thu, Jul 16, 2015 at 5:59 AM, Andrew Haley <aph@redhat.com> wrote:
> On 16/07/15 10:40, Jeffrey Walton wrote:
>>>> 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.
>
> Well, reluctant as I am to argue with Ian, the definition of volatile
> I used is a direct quote from the standard. There are problems with
> volatile as defined, it's true: for example, nowhere is it specified
> exactly what constitutes a memory access. And Ian is quite right to
> say that the standard doesn't guarantee that a pointer-to-volatile
> should be handled as though it pointed to a volatile object. But in
> this case, with GCC, I think it's fine.
>
Yeah, it kind of crossed my wires for a moment. There's a handful of
folks I always listen to when it comes to GCC, and you and Ian are two
of them :o
If you tell me the memory barrier works to tame the optimizer for a
function, then that's what I will use.
Jeff