Re: [RFC] LKMM: Add volatile_if()
From: Segher Boessenkool
Date: Sun Jun 06 2021 - 09:22:06 EST
On Sat, Jun 05, 2021 at 09:43:33PM -0700, Paul E. McKenney wrote:
> So gcc might some day note a do-nothing asm and duplicate it for
> the sole purpose of collapsing the "then" and "else" clauses. I
> guess I need to keep my paranoia for the time being, then. :-/
Or a "do-something" asm, even. What it does is make sure it is executed
on the real machine exactly like on the abstract machine. That is how C
is defined, what a compiler *does*.
The programmer does not have any direct control over the generated code.
> Of course, there is no guarantee that gcc won't learn about
> assembler constants. :-/
I am not sure what you call an "assembler constant" here. But you can
be sure that GCC will not start doing anything here. GCC does not try
to understand what you wrote in an inline asm, it just fills in the
operands and that is all. It can do all the same things to it that it
can do to any other code of course: duplicate it, deduplicate it,
frobnicate it, etc.
Segher