Skip to content

Commit 5b2fc2b

Browse files
[sanitizer_common][AIX] Use scoped pragma to suppress atomic alignment warnings (#139272)
Have the warning suppression apply only to the code that is currently affected. The suppression is guarded via preprocessor conditions to cases where it is tested and known to be needed. Issue: #138916 Co-authored-by: Hubert Tong <[email protected]>
1 parent fb017a5 commit 5b2fc2b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414
#ifndef SANITIZER_ATOMIC_CLANG_H
1515
#define SANITIZER_ATOMIC_CLANG_H
1616

17+
// Helper to suppress warnings related to 8-byte atomic accesses when the target
18+
// is 32-bit AIX (where such accesses use libatomic).
19+
#if defined(_AIX) && !defined(__powerpc64__) && defined(__clang__)
20+
# define SANITIZER_IGNORE_ATOMIC_ALIGNMENT_BEGIN \
21+
_Pragma("clang diagnostic push") \
22+
_Pragma("clang diagnostic ignored \"-Watomic-alignment\"")
23+
# define SANITIZER_IGNORE_ATOMIC_ALIGNMENT_END _Pragma("clang diagnostic pop")
24+
#else
25+
# define SANITIZER_IGNORE_ATOMIC_ALIGNMENT_BEGIN
26+
# define SANITIZER_IGNORE_ATOMIC_ALIGNMENT_END
27+
#endif
28+
1729
namespace __sanitizer {
1830

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

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

108+
SANITIZER_IGNORE_ATOMIC_ALIGNMENT_END
109+
95110
} // namespace __sanitizer
96111

97112
#undef ATOMIC_ORDER

0 commit comments

Comments
 (0)