[libc-commits] [libc] [libc][NFC] Selectively disable GCC warnings (PR #78462)

via libc-commits libc-commits at lists.llvm.org
Wed Jan 17 08:24:38 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Guillaume Chatelet (gchatelet)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/78462.diff


2 Files Affected:

- (modified) libc/src/string/memory_utils/op_x86.h (+7) 
- (modified) libc/src/string/memory_utils/utils.h (+3-1) 


``````````diff
diff --git a/libc/src/string/memory_utils/op_x86.h b/libc/src/string/memory_utils/op_x86.h
index 6ae9583627bd6d3..f7897a7f9fd7205 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 5cd716e033d6a4c..543d45b7c4e33e3 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

``````````

</details>


https://github.com/llvm/llvm-project/pull/78462


More information about the libc-commits mailing list