Re: Control Dependencies vs C Compilers

Nick Clifton
2020-10-06T15:16:39Z

Hi Guys,

OK, so playing the devils advocate here...

> Mostly I just want the compiler people to say they'll guarantee the
> behaviour if we do 'X'. If 'X' happens to be 'any dynamic branch headed
> by a volatile load' that's fine by me.

Is a compiler hack really the right way to go here ?

After all, if you do get this feature added it will make it
harder to compile the kernel with other compilers (*cough
LLVM cough*), or older versions of gcc. Plus code like this
is often subject to very aggressive optimization and all it
takes is one bug in the compiler implementation and you lose
the gains you were trying for.

My suggestion as an alternative is to use assembler instead.
That way you can guarantee that you get the instructions you
want in the order that you want them. It should be fairly
straightforward to create a macro or inline function that
contains the necessary code and this can be done once and
then used wherever the functionality is required.

Cheers
Nick