[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
Thu Mar 5 02:36:28 PST 2026


================
@@ -2336,6 +2319,16 @@ private:
 #  endif
   }
 
+  // Prevents speculative load before short/long state is determined.
+  // The following functions are no-ops outside of AddressSanitizer mode.
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_memory_barrier() const {
+#  if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS_FOR_STRING
+    if (__libcpp_is_constant_evaluated())
+      return;
+    __asm__ volatile("" ::: "memory");
----------------
philnik777 wrote:

```suggestion
    asm volatile("" ::: "memory");
```
We have it, so we might as well use it.

https://github.com/llvm/llvm-project/pull/184693


More information about the libcxx-commits mailing list