From 1107465f31f59dd73dfdfcca764d1a0bccdbe306 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 13 Jan 2025 22:22:45 +0100 Subject: [PATCH] Avoid clang warning in -fsanitize=undefined -O mode (master only) Fixes #11645 --- gcore/rasterio.cpp | 16 ++++++++++++++++ gcore/rasterio_ssse3.cpp | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/gcore/rasterio.cpp b/gcore/rasterio.cpp index fed171e9c8e1..bc06c11a8d7c 100644 --- a/gcore/rasterio.cpp +++ b/gcore/rasterio.cpp @@ -5944,6 +5944,11 @@ __attribute__((optimize("tree-vectorize"))) #if defined(__GNUC__) __attribute__((noinline)) #endif +#if defined(__clang__) && !defined(__INTEL_CLANG_COMPILER) +// clang++ -O2 -fsanitize=undefined fails to vectorize, ignore that warning +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpass-failed" +#endif static void GDALInterleave2Byte(const uint8_t *CPL_RESTRICT pSrc, uint8_t *CPL_RESTRICT pDst, size_t nIters) @@ -5957,6 +5962,9 @@ GDALInterleave2Byte(const uint8_t *CPL_RESTRICT pSrc, pDst[2 * i + 1] = pSrc[i + 1 * nIters]; } } +#if defined(__clang__) && !defined(__INTEL_CLANG_COMPILER) +#pragma clang diagnostic pop +#endif #endif @@ -6039,6 +6047,11 @@ __attribute__((optimize("tree-vectorize"))) #if defined(__GNUC__) __attribute__((noinline)) #endif +#if defined(__clang__) && !defined(__INTEL_CLANG_COMPILER) +// clang++ -O2 -fsanitize=undefined fails to vectorize, ignore that warning +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpass-failed" +#endif static void GDALInterleave4Byte(const uint8_t *CPL_RESTRICT pSrc, uint8_t *CPL_RESTRICT pDst, size_t nIters) @@ -6054,6 +6067,9 @@ GDALInterleave4Byte(const uint8_t *CPL_RESTRICT pSrc, pDst[4 * i + 3] = pSrc[i + 3 * nIters]; } } +#if defined(__clang__) && !defined(__INTEL_CLANG_COMPILER) +#pragma clang diagnostic pop +#endif #endif diff --git a/gcore/rasterio_ssse3.cpp b/gcore/rasterio_ssse3.cpp index 9bf80e34096a..8bbfdab4a134 100644 --- a/gcore/rasterio_ssse3.cpp +++ b/gcore/rasterio_ssse3.cpp @@ -420,6 +420,11 @@ __attribute__((optimize("tree-vectorize"))) #if defined(__GNUC__) __attribute__((noinline)) #endif +#if defined(__clang__) && !defined(__INTEL_CLANG_COMPILER) +// clang++ -O2 -fsanitize=undefined fails to vectorize, ignore that warning +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpass-failed" +#endif static void GDALInterleave3Byte_SSSE3(const uint8_t *CPL_RESTRICT pSrc, uint8_t *CPL_RESTRICT pDst, size_t nIters) @@ -434,6 +439,9 @@ GDALInterleave3Byte_SSSE3(const uint8_t *CPL_RESTRICT pSrc, pDst[3 * i + 2] = pSrc[i + 2 * nIters]; } } +#if defined(__clang__) && !defined(__INTEL_CLANG_COMPILER) +#pragma clang diagnostic pop +#endif #endif