Re: [PATCH v3 3/3] arm64, compiler-context-analysis: Permit alias analysis through __READ_ONCE() with CONFIG_LTO=y
From: Boqun Feng <boqun@kernel.org>
Date: 2026-02-18 19:34:45
Also in:
lkml, llvm
From: Boqun Feng <boqun@kernel.org>
Date: 2026-02-18 19:34:45
Also in:
lkml, llvm
On Tue, Feb 17, 2026 at 08:32:32AM -0800, Linus Torvalds wrote:
On Tue, 17 Feb 2026 at 08:23, Linus Torvalds [off-list ref] wrote:quoted
But last time I looked at it - which was admittedly a few years ago - the compilers we supported didn't actually do anything reasonable here (ie the built-in atomics were fundamentally worse than the ones we do by hand, and even basic things like __atomic_load_n() weren't actually; better than just using 'volatile'. Maybe that has changed. We've upgraded minimum compilers since.I just checked a few test-cases, and I don't think anything has changed. All the trivial things where __atomic_load_n(__ATOMIC_RELAXED) *could* do better than just our old code using "cast pointer to volatile" resulted in no better code generation.
By any chance, could you share the test cases? It'll be really helpful to represent what semantics we really want to compiler/language folks. [Cc Alice and Gary] Regards, Boqun
So we're sticking to that "cast to volatile" not because it's great,
but because it continues to be reliable and no worse than the fancy
modern versions.
But at least it's explicit in the code, not hidden away in code that
*looks* like it just dereferences another field in a structure.
Linus