[libcxx-commits] [libcxx] [libc++][string] Replace ASAN volatile wrapper with memory barrier (PR #184693)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 6 23:47:15 PST 2026
philnik777 wrote:
> > Having an opt-in attribute lik e `[[as an_sbo_container]]` or something should be perfectly fine, no? Then any code for that class would have the performance penalty, but that's already the case with volatile/memory barriers.
>
> Oh, I see. My "idea" of proper solution was: "no additional changes in user code". To my taste it's better than barrier as we don't need to think about placement of barriers, but not significantly better? I guess this is a new option to consider. Thanks!
The improvement I see is that the compiler will do the correct thing, and the library doesn't have to add workarounds anymore. "If you annotate parts of an object, apply this attribute to it" seems rather trivial to understand. I'd also expect this would actually improve performance, since the compiler knows what we're trying to tell it and don't just add a memory barrier for _everything_. I haven't thought about this deeply, so I don't know whether I'd missing something problematic here.
https://github.com/llvm/llvm-project/pull/184693
More information about the libcxx-commits
mailing list