[Info-vax] LLVM, volatile and async VMS I/O and system calls
Jan-Erik Söderholm
jan-erik.soderholm at telia.com
Sun Oct 3 05:21:30 EDT 2021
Den 2021-10-03 kl. 01:06, skrev chris:
>
> So, it really comes down to optimiser choice of instruction, depending
> on the use of the volatile keyword. Perhaps optimisers might optimise
> such reads out, but that common ?.
Optimizing out code not needed is one of the most common things that
optimizers does. A very short example.
int a;
int b;
void main() {
a = 10;
b = a;
b = a;
}
The second assignment to b will simply be removed since it is
a duplicate of the first and the value of a has not changed, at
least not as far as the compiler can see.
Compare with:
int volatile a;
int b;
void main() {
a = 10;
b = a;
b = a;
}
This tells the compiler that the value of a can change outside of
the current compile unit and both assignments will be left to be
done and the value of b could be different after each assignment.
The first generates 7 Alpha instructions and the second 9 instructions.
Now, this was a very simple example, and a would probably point to some
common area in memory shared by multiple processes, or to some hardware
register that is changed outside of any code on the system. Or, as in the
example from Simon, a buffer that is written to by the I/O sub-system.
And no, I do not think that you are trolling, I think that you simply
do not understand what Simon is trying to say. Either just some simple
misunderstanding, or maybe you just to not understand the concept
of "volatile" in this context.
More information about the Info-vax
mailing list