RE: [RFC] LKMM: Add volatile_if()

David Laight
2021-06-08T12:48:49Z

From: Peter Zijlstra
> Sent: 04 June 2021 11:12
>
> Hi!
>
> With optimizing compilers becoming more and more agressive and C so far
> refusing to acknowledge the concept of control-dependencies even while
> we keep growing the amount of reliance on them, things will eventually
> come apart.
>
> There have been talks with toolchain people on how to resolve this; one
> suggestion was allowing the volatile qualifier on branch statements like
> 'if', but so far no actual compiler has made any progress on this.
>
> Rather than waiting any longer, provide our own construct based on that
> suggestion. The idea is by Alan Stern and refined by Paul and myself.
>
> Code generation is sub-optimal (for the weak architectures) since we're
> forced to convert the condition into another and use a fixed conditional
> branch instruction, but shouldn't be too bad.

What happens on mips-like architectures (I think includes riscv)
that have 'compare two registers and branch' instructions rather
than a more traditional 'flags register'?

The generated code it likely to be somewhat different.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)