Skip to content

[sanitizer_common][AIX] Use scoped pragma to suppress atomic alignment warnings #139272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
#ifndef SANITIZER_ATOMIC_CLANG_H
#define SANITIZER_ATOMIC_CLANG_H

// Helper to suppress warnings related to 8-byte atomic accesses when the target
// is 32-bit AIX (where such accesses use libatomic).
#if defined(_AIX) && !defined(__powerpc64__) && defined(__clang__)
# define SANITIZER_IGNORE_ATOMIC_ALIGNMENT_BEGIN \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Watomic-alignment\"")
# define SANITIZER_IGNORE_ATOMIC_ALIGNMENT_END _Pragma("clang diagnostic pop")
#else
# define SANITIZER_IGNORE_ATOMIC_ALIGNMENT_BEGIN
# define SANITIZER_IGNORE_ATOMIC_ALIGNMENT_END
#endif

namespace __sanitizer {

// We use the compiler builtin atomic operations for loads and stores, which
Expand All @@ -35,6 +47,7 @@ inline void proc_yield(int cnt) {
#endif
}

SANITIZER_IGNORE_ATOMIC_ALIGNMENT_BEGIN
template <typename T>
inline typename T::Type atomic_load(const volatile T *a, memory_order mo) {
DCHECK(mo == memory_order_relaxed || mo == memory_order_consume ||
Expand Down Expand Up @@ -92,6 +105,8 @@ inline bool atomic_compare_exchange_weak(volatile T *a, typename T::Type *cmp,
return atomic_compare_exchange_strong(a, cmp, xchg, mo);
}

SANITIZER_IGNORE_ATOMIC_ALIGNMENT_END

} // namespace __sanitizer

#undef ATOMIC_ORDER
Expand Down
Loading