[libcxx-commits] [PATCH] D125313: [libc++] Fix warnings on AIX 32 bit

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 10 06:57:14 PDT 2022


ldionne created this revision.
ldionne added reviewers: mstorsjo, DavidSpickett.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

The compiler complains about large atomic operation potentially incurring
a performance penalty with -Watomic-alignment, which is turned into an
error.

Note that I don't really intend to commit this patch as-is -- I mostly
want to have a discussion to find out why this warning begun. I don't
intend that the right fix is simply going to silence the warning, at
least not from within the headers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125313

Files:
  libcxx/include/atomic


Index: libcxx/include/atomic
===================================================================
--- libcxx/include/atomic
+++ libcxx/include/atomic
@@ -945,7 +945,14 @@
 _LIBCPP_INLINE_VISIBILITY
 _Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const volatile* __a, memory_order __order) _NOEXCEPT {
     using __ptr_type = typename remove_const<decltype(__a->__a_value)>::type*;
+#ifdef _AIX
+    _LIBCPP_DIAGNOSTIC_PUSH
+    _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(-Watomic-alignment)
+#endif
     return __c11_atomic_load(const_cast<__ptr_type>(&__a->__a_value), static_cast<__memory_order_underlying_t>(__order));
+#ifdef _AIX
+    _LIBCPP_DIAGNOSTIC_POP
+#endif
 }
 template<class _Tp>
 _LIBCPP_INLINE_VISIBILITY
@@ -994,6 +1001,10 @@
     return __c11_atomic_compare_exchange_weak(&__a->__a_value, __expected, __value,  static_cast<__memory_order_underlying_t>(__success), static_cast<__memory_order_underlying_t>(__to_failure_order(__failure)));
 }
 
+#ifdef _AIX
+  _LIBCPP_DIAGNOSTIC_PUSH
+  _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(-Watomic-alignment)
+#endif
 template<class _Tp>
 _LIBCPP_INLINE_VISIBILITY
 _Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
@@ -1004,6 +1015,9 @@
 _Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp> * __a, _Tp __delta, memory_order __order) _NOEXCEPT {
     return __c11_atomic_fetch_add(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
 }
+#ifdef _AIX
+  _LIBCPP_DIAGNOSTIC_POP
+#endif
 
 template<class _Tp>
 _LIBCPP_INLINE_VISIBILITY
@@ -1019,7 +1033,14 @@
 template<class _Tp>
 _LIBCPP_INLINE_VISIBILITY
 _Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
+#ifdef _AIX
+    _LIBCPP_DIAGNOSTIC_PUSH
+    _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(-Watomic-alignment)
+#endif
     return __c11_atomic_fetch_sub(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+#ifdef _AIX
+    _LIBCPP_DIAGNOSTIC_POP
+#endif
 }
 template<class _Tp>
 _LIBCPP_INLINE_VISIBILITY


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125313.428359.patch
Type: text/x-patch
Size: 2079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220510/dce4087a/attachment.bin>


More information about the libcxx-commits mailing list