[libc-commits] [libc] bc4f3e3 - [libc][NFC] Selectively disable GCC warnings (#78462)
via libc-commits
libc-commits at lists.llvm.org
Thu Jan 18 01:36:25 PST 2024
Author: Guillaume Chatelet
Date: 2024-01-18T10:36:21+01:00
New Revision: bc4f3e31a99ad11b385f68634aa9fbe2cbdd7031
URL: https://github.com/llvm/llvm-project/commit/bc4f3e31a99ad11b385f68634aa9fbe2cbdd7031
DIFF: https://github.com/llvm/llvm-project/commit/bc4f3e31a99ad11b385f68634aa9fbe2cbdd7031.diff
LOG: [libc][NFC] Selectively disable GCC warnings (#78462)
Added:
Modified:
libc/src/string/memory_utils/op_x86.h
libc/src/string/memory_utils/utils.h
Removed:
################################################################################
diff --git a/libc/src/string/memory_utils/op_x86.h b/libc/src/string/memory_utils/op_x86.h
index 6ae9583627bd6d..2852636c48a74d 100644
--- a/libc/src/string/memory_utils/op_x86.h
+++ b/libc/src/string/memory_utils/op_x86.h
@@ -116,6 +116,14 @@ LIBC_INLINE MemcmpReturnType cmp_neq<uint64_t>(CPtr p1, CPtr p2,
return cmp_neq_uint64_t(a, b);
}
+// SIMD types are defined with attributes. e.g., '__m128i' is defined as
+// long long __attribute__((__vector_size__(16), __aligned__(16)))
+// When we use these SIMD types in template specialization GCC complains:
+// "ignoring attributes on template argument ā__m128iā [-Wignored-attributes]"
+// Therefore, we disable this warning in this file.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wignored-attributes"
+
///////////////////////////////////////////////////////////////////////////////
// Specializations for __m128i
#if defined(__SSE4_1__)
@@ -304,6 +312,8 @@ LIBC_INLINE MemcmpReturnType cmp_neq<__m512i>(CPtr p1, CPtr p2, size_t offset) {
}
#endif // __AVX512BW__
+#pragma GCC diagnostic pop
+
} // namespace LIBC_NAMESPACE::generic
#endif // LIBC_TARGET_ARCH_IS_X86_64
diff --git a/libc/src/string/memory_utils/utils.h b/libc/src/string/memory_utils/utils.h
index 5cd716e033d6a4..543d45b7c4e33e 100644
--- a/libc/src/string/memory_utils/utils.h
+++ b/libc/src/string/memory_utils/utils.h
@@ -89,9 +89,11 @@ LIBC_INLINE void memcpy_inline(void *__restrict dst,
// In memory functions `memcpy_inline` is instantiated several times with
//
diff erent value of the Size parameter. This doesn't play well with GCC's
// Value Range Analysis that wrongly detects out of bounds accesses. We
- // disable the 'array-bounds' warning for the purpose of this function.
+ // disable these warnings for the purpose of this function.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
+#pragma GCC diagnostic ignored "-Wstringop-overread"
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
for (size_t i = 0; i < Size; ++i)
static_cast<char *>(dst)[i] = static_cast<const char *>(src)[i];
#pragma GCC diagnostic pop
More information about the libc-commits
mailing list