[Info-vax] yet another sys$qiow question

Simon Clubley clubley at remove_me.eisner.decus.org-Earth.UFP
Thu Aug 20 08:48:00 EDT 2015


On 2015-08-20, Craig A. Berry <craigberry at nospam.mac.com> wrote:
> On 8/19/15 8:17 AM, Simon Clubley wrote:
>
>> Although I don't write empty loops for non-volatile variables, gcc can
>> (silently) optimise out other chunks of code that it thinks will never
>> be reached or is otherwise redundant so I would have to consider the
>> possibility that LLVM will do the same as well and that in some
>> circumstances it might do it with empty non-volatile while loops as well.
>
> Since the current Ada on VMS is based on gcc, how can it do concurrency
> if gcc can't? Does it generate lots of volatile statements or just
> disable optimizations?

I was talking about optimisations performed at compile time based on the
structure of the code.

Example 1:

	while(1)
		{
		{whatever}
		}

	while(1)
		{
		{another bunch of whatever}
		}

Example 2:

	{some code}
	while(i == 0)	/* i is _not_ volatile */
		{	/* This is an empty loop */
		}
	{some more code}

In example 1, I've seen gcc remove the code for the second while loop
completely because it will never be reached. (I sometimes use this
construct during debugging by adding the first while loop in front of
the real while loop to dump some registers and to stop the real while
loop from executing).

I've never written code in the style of example 2, at least when using
_non-volatile_ variables, but I can see an aggressive optimiser
(especially when it's been told to optimise for size) actually removing
that while loop when only non-volatile variables are involved.

Example 2 could cause a poorly written program to break if it was
busy-waiting on a non-volatile IOSB block.

Simon.

-- 
Simon Clubley, clubley at remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world



More information about the Info-vax mailing list