Merge pull request #59229 from rschu1ze/cleanup-msan-usage

Minor cleanup of msan usage
This commit is contained in:
Robert Schulze 2024-01-29 20:39:06 +01:00 committed by GitHub
commit 8ddda0caf0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 25 deletions

View File

@ -1,6 +1,7 @@
#if defined(__ELF__) && !defined(OS_FREEBSD) #if defined(__ELF__) && !defined(OS_FREEBSD)
#include <Common/SymbolIndex.h> #include <Common/SymbolIndex.h>
#include <Common/MemorySanitizer.h>
#include <algorithm> #include <algorithm>
#include <optional> #include <optional>
@ -55,21 +56,6 @@ Otherwise you will get only exported symbols from program headers.
*/ */
#if defined(__clang__)
# pragma clang diagnostic ignored "-Wreserved-id-macro"
# pragma clang diagnostic ignored "-Wunused-macros"
#endif
#define __msan_unpoison_string(X) // NOLINT
#define __msan_unpoison(X, Y) // NOLINT
#if defined(ch_has_feature)
# if ch_has_feature(memory_sanitizer)
# undef __msan_unpoison_string
# undef __msan_unpoison
# include <sanitizer/msan_interface.h>
# endif
#endif
namespace DB namespace DB
{ {

View File

@ -6,14 +6,15 @@
#include <Compression/CompressionFactory.h> #include <Compression/CompressionFactory.h>
#include <Compression/CompressionInfo.h> #include <Compression/CompressionInfo.h>
#include <Poco/Logger.h> #include <Poco/Logger.h>
#include <Common/randomSeed.h>
#include <Common/logger_useful.h>
#include "libaccel_config.h"
#include <Common/MemorySanitizer.h> #include <Common/MemorySanitizer.h>
#include <Common/logger_useful.h>
#include <Common/randomSeed.h>
#include <base/scope_guard.h> #include <base/scope_guard.h>
#include <base/getPageSize.h> #include <base/getPageSize.h>
#include <immintrin.h>
#include "libaccel_config.h"
#include <immintrin.h>
namespace DB namespace DB
{ {
@ -416,9 +417,7 @@ UInt32 CompressionCodecDeflateQpl::doCompressData(const char * source, UInt32 so
{ {
/// QPL library is using AVX-512 with some shuffle operations. /// QPL library is using AVX-512 with some shuffle operations.
/// Memory sanitizer don't understand if there was uninitialized memory in SIMD register but it was not used in the result of shuffle. /// Memory sanitizer don't understand if there was uninitialized memory in SIMD register but it was not used in the result of shuffle.
#if defined(MEMORY_SANITIZER)
__msan_unpoison(dest, getMaxCompressedDataSize(source_size)); __msan_unpoison(dest, getMaxCompressedDataSize(source_size));
#endif
Int32 res = HardwareCodecDeflateQpl::RET_ERROR; Int32 res = HardwareCodecDeflateQpl::RET_ERROR;
if (DeflateQplJobHWPool::instance().isJobPoolReady()) if (DeflateQplJobHWPool::instance().isJobPoolReady())
res = hw_codec->doCompressData(source, source_size, dest, getMaxCompressedDataSize(source_size)); res = hw_codec->doCompressData(source, source_size, dest, getMaxCompressedDataSize(source_size));
@ -439,9 +438,7 @@ void CompressionCodecDeflateQpl::doDecompressData(const char * source, UInt32 so
{ {
/// QPL library is using AVX-512 with some shuffle operations. /// QPL library is using AVX-512 with some shuffle operations.
/// Memory sanitizer don't understand if there was uninitialized memory in SIMD register but it was not used in the result of shuffle. /// Memory sanitizer don't understand if there was uninitialized memory in SIMD register but it was not used in the result of shuffle.
#if defined(MEMORY_SANITIZER)
__msan_unpoison(dest, uncompressed_size); __msan_unpoison(dest, uncompressed_size);
#endif
/// Device IOTLB miss has big perf. impact for IAA accelerators. /// Device IOTLB miss has big perf. impact for IAA accelerators.
/// To avoid page fault, we need touch buffers related to accelerator in advance. /// To avoid page fault, we need touch buffers related to accelerator in advance.
touchBufferWithZeroFilling(dest, uncompressed_size); touchBufferWithZeroFilling(dest, uncompressed_size);

View File

@ -3,6 +3,7 @@
#include <Functions/FunctionsHashing.h> #include <Functions/FunctionsHashing.h>
#include <Common/HashTable/ClearableHashMap.h> #include <Common/HashTable/ClearableHashMap.h>
#include <Common/HashTable/Hash.h> #include <Common/HashTable/Hash.h>
#include <Common/MemorySanitizer.h>
#include <Common/UTF8Helpers.h> #include <Common/UTF8Helpers.h>
#include <Core/Defines.h> #include <Core/Defines.h>
@ -108,10 +109,8 @@ struct NgramDistanceImpl
if constexpr (case_insensitive) if constexpr (case_insensitive)
{ {
#if defined(MEMORY_SANITIZER)
/// Due to PODArray padding accessing more elements should be OK /// Due to PODArray padding accessing more elements should be OK
__msan_unpoison(code_points + (N - 1), padding_offset * sizeof(CodePoint)); __msan_unpoison(code_points + (N - 1), padding_offset * sizeof(CodePoint));
#endif
/// We really need template lambdas with C++20 to do it inline /// We really need template lambdas with C++20 to do it inline
unrollLowering<N - 1>(code_points, std::make_index_sequence<padding_offset>()); unrollLowering<N - 1>(code_points, std::make_index_sequence<padding_offset>());
} }