[Info-vax] LLVM, volatile and async VMS I/O and system calls

chris chris-nospam at tridac.net
Sat Oct 2 09:33:37 EDT 2021


On 09/28/21 19:32, Simon Clubley wrote:

>
> The whole point of volatile is that the compiler doesn't need to know.
> When the variable _is_ accessed again in the code, the read is left in
> instead of possibly being deleted by the optimiser.

A buffer would never be deleted by an optimiser, but if you think so,
please explain.

> The whole point of volatile is that it doesn't need to predict the
> future. The variable is always re-read before the contents are used
> for something and as I clarified a few messages back, it's not about
> adding code, but instead about not removing code the optimiser would
> otherwise think is redundant.
>

So tell me, what exactly "rereads" the variable, code added by the
compiler, or what ?

> No. The concern was that people might not be correctly marking buffers
> and data structures as volatile when using system services in full async
> mode and that might catch them with a compiler with a different optimiser
> (ie: LLVM).
>

Perhaps, but you can give no good reason why that might be the case,
or technical argument to support such a theory.

>>>
>>> I've just checked some FreeBSD headers available online and it
>>> turns out that AIO on FreeBSD also marks the transfer buffer
>>> as volatile.
>>>
>>
>> Well, there is a lot of cross fertilisation between the two OS. The
>> only reason I can think of for the pointer to be declared with
>> a volatile keyword is that if the buffer is declared volatile, then
>> the point also needs to be to avoid whinges about incompatible types.
>> Can see no reason for it otherwise...
>>
>
> It's not a volatile pointer Chris, it's a normal pointer to
> a volatile buffer. The only thing that's volatile is the buffer
> behind the pointer (which is how it should be). The pointer itself
> is not volatile.

No, but the point I was making that the pointer is declared volatile
to avoid complier whinges about incompatible  types, if you
had read what I said. If something is declared volatile, then the
compiler will take note, whether it needs to or not, but will have
no effect on the resulting code.

See a lot of use of volatile where it's not needed, because so many
do not understand it's use. Does no harm, but shows lack of
understanding...

Chris



More information about the Info-vax mailing list