Re: C aggregate passing (Rust kernel policy)

Martin Uecker
2025-02-28T08:33:09Z

Am Freitag, dem 28.02.2025 um 09:08 +0100 schrieb Ralf Jung:

>
> (From a different email)
> > It sounds you want to see the semantics strengthened in case
> > of a data race from there being UB to having either the old
> > or new value being visible to another thread, where at some
> > point this could change but needs to be consistent for a
> > single access as expressed in the source code.
>
> This would definitely impact optimizations of purely sequential code. Maybe that
> is a price worth paying, but one of the goals of the C++ model was that if you
> don't use threads, you shouldn't pay for them. Disallowing rematerialization in
> entirely sequential code (just one of the likely many consequences of making
> data races not UB) contradicts that goal.

This is the feedback I now also got from GCC, i.e. there are cases where
register allocator would indeed rematerialize a load and they think this is
reasonable.

> Given that even in highly concurrent
> programs, most accesses are entirely sequential, it doesn't seem unreasonable to
> say that the exceptional case needs to be marked in the program (especially if
> you have a type system which helps ensure that you don't forget to do so).

Martin