[libc-commits] [libc] [libc][NFC] Selectively disable GCC warnings (PR #78462)
Guillaume Chatelet via libc-commits
libc-commits at lists.llvm.org
Wed Jan 17 08:23:48 PST 2024
https://github.com/gchatelet created https://github.com/llvm/llvm-project/pull/78462
None
>From debf7314ce152919dcfdca531526c561d37dc298 Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet <gchatelet at google.com>
Date: Wed, 17 Jan 2024 16:23:20 +0000
Subject: [PATCH] [libc][NFC] Selectively disable GCC warnings
---
libc/src/string/memory_utils/op_x86.h | 7 +++++++
libc/src/string/memory_utils/utils.h | 4 +++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/libc/src/string/memory_utils/op_x86.h b/libc/src/string/memory_utils/op_x86.h
index 6ae9583627bd6d..f7897a7f9fd720 100644
--- a/libc/src/string/memory_utils/op_x86.h
+++ b/libc/src/string/memory_utils/op_x86.h
@@ -25,6 +25,11 @@
#include <immintrin.h>
#endif
+// Disable GCC complaining about missing attributes when using SIMD types in
+// template specializations.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wignored-attributes"
+
// Define fake functions to prevent the compiler from failing on undefined
// functions in case the CPU extension is not present.
#if !defined(__AVX512BW__) && (defined(_MSC_VER) || defined(__SCE__))
@@ -306,6 +311,8 @@ LIBC_INLINE MemcmpReturnType cmp_neq<__m512i>(CPtr p1, CPtr p2, size_t offset) {
} // namespace LIBC_NAMESPACE::generic
+#pragma GCC diagnostic pop
+
#endif // LIBC_TARGET_ARCH_IS_X86_64
#endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_X86_H
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
// different 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