From e6cfd11948a39a0933568bf5219fd308250b1279 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Tue, 1 Nov 2022 10:29:22 +0000 Subject: [PATCH 1/8] prefix assume_aligned to avoid clash with std::assume_aligned in c++20 --- src/util/arch/common/simd_utils.h | 4 ++-- src/util/arch/x86/simd_utils.h | 4 ++-- src/util/simd_utils.h | 8 ++++---- src/util/supervector/arch/arm/impl.cpp | 2 +- src/util/supervector/arch/x86/impl.cpp | 6 +++--- src/util/supervector/supervector.hpp | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/util/arch/common/simd_utils.h b/src/util/arch/common/simd_utils.h index 90ae80b06..d142ee9a6 100644 --- a/src/util/arch/common/simd_utils.h +++ b/src/util/arch/common/simd_utils.h @@ -254,7 +254,7 @@ static really_inline m256 loadu2x128(const void *ptr) { // aligned store static really_inline void store256(void *ptr, m256 a) { assert(ISALIGNED_N(ptr, alignof(m256))); - ptr = assume_aligned(ptr, 16); + ptr = vectorscan_assume_aligned(ptr, 16); *(m256 *)ptr = a; } @@ -486,7 +486,7 @@ static really_inline m384 load384(const void *ptr) { // aligned store static really_inline void store384(void *ptr, m384 a) { assert(ISALIGNED_16(ptr)); - ptr = assume_aligned(ptr, 16); + ptr = vectorscan_assume_aligned(ptr, 16); *(m384 *)ptr = a; } diff --git a/src/util/arch/x86/simd_utils.h b/src/util/arch/x86/simd_utils.h index 924a91c6a..ba2bf26f1 100644 --- a/src/util/arch/x86/simd_utils.h +++ b/src/util/arch/x86/simd_utils.h @@ -278,14 +278,14 @@ static really_inline m128 andnot128(m128 a, m128 b) { // aligned load static really_inline m128 load128(const void *ptr) { assert(ISALIGNED_N(ptr, alignof(m128))); - ptr = assume_aligned(ptr, 16); + ptr = vectorscan_assume_aligned(ptr, 16); return _mm_load_si128((const m128 *)ptr); } // aligned store static really_inline void store128(void *ptr, m128 a) { assert(ISALIGNED_N(ptr, alignof(m128))); - ptr = assume_aligned(ptr, 16); + ptr = vectorscan_assume_aligned(ptr, 16); *(m128 *)ptr = a; } diff --git a/src/util/simd_utils.h b/src/util/simd_utils.h index 2913c4fe6..2f0012c62 100644 --- a/src/util/simd_utils.h +++ b/src/util/simd_utils.h @@ -40,17 +40,17 @@ // it's available. Note that we need to handle C or C++ compilation. #ifdef __cplusplus # ifdef HAVE_CXX_BUILTIN_ASSUME_ALIGNED -# define assume_aligned(x, y) __builtin_assume_aligned((x), (y)) +# define vectorscan_assume_aligned(x, y) __builtin_assume_aligned((x), (y)) # endif #else # ifdef HAVE_CC_BUILTIN_ASSUME_ALIGNED -# define assume_aligned(x, y) __builtin_assume_aligned((x), (y)) +# define vectorscan_assume_aligned(x, y) __builtin_assume_aligned((x), (y)) # endif #endif // Fallback to identity case. -#ifndef assume_aligned -#define assume_aligned(x, y) (x) +#ifndef vectorscan_assume_aligned +#define vectorscan_assume_aligned(x, y) (x) #endif #ifdef __cplusplus diff --git a/src/util/supervector/arch/arm/impl.cpp b/src/util/supervector/arch/arm/impl.cpp index 5283ab00d..55f6c55c1 100644 --- a/src/util/supervector/arch/arm/impl.cpp +++ b/src/util/supervector/arch/arm/impl.cpp @@ -518,7 +518,7 @@ template <> really_inline SuperVector<16> SuperVector<16>::load(void const *ptr) { assert(ISALIGNED_N(ptr, alignof(SuperVector::size))); - ptr = assume_aligned(ptr, SuperVector::size); + ptr = vectorscan_assume_aligned(ptr, SuperVector::size); return {vld1q_s32((const int32_t *)ptr)}; } diff --git a/src/util/supervector/arch/x86/impl.cpp b/src/util/supervector/arch/x86/impl.cpp index 49fbee99d..a807c84e3 100644 --- a/src/util/supervector/arch/x86/impl.cpp +++ b/src/util/supervector/arch/x86/impl.cpp @@ -515,7 +515,7 @@ template <> really_inline SuperVector<16> SuperVector<16>::load(void const *ptr) { assert(ISALIGNED_N(ptr, alignof(SuperVector::size))); - ptr = assume_aligned(ptr, SuperVector::size); + ptr = vectorscan_assume_aligned(ptr, SuperVector::size); return _mm_load_si128((const m128 *)ptr); } @@ -1119,7 +1119,7 @@ template <> really_inline SuperVector<32> SuperVector<32>::load(void const *ptr) { assert(ISALIGNED_N(ptr, alignof(SuperVector::size))); - ptr = assume_aligned(ptr, SuperVector::size); + ptr = vectorscan_assume_aligned(ptr, SuperVector::size); return {_mm256_load_si256((const m256 *)ptr)}; } @@ -1769,7 +1769,7 @@ template <> really_inline SuperVector<64> SuperVector<64>::load(void const *ptr) { assert(ISALIGNED_N(ptr, alignof(SuperVector::size))); - ptr = assume_aligned(ptr, SuperVector::size); + ptr = vectorscan_assume_aligned(ptr, SuperVector::size); return {_mm512_load_si512((const m512 *)ptr)}; } diff --git a/src/util/supervector/supervector.hpp b/src/util/supervector/supervector.hpp index fef5f09f6..c02005757 100644 --- a/src/util/supervector/supervector.hpp +++ b/src/util/supervector/supervector.hpp @@ -76,17 +76,17 @@ using Z_TYPE = u32; // it's available. Note that we need to handle C or C++ compilation. #ifdef __cplusplus # ifdef HAVE_CXX_BUILTIN_ASSUME_ALIGNED -# define assume_aligned(x, y) __builtin_assume_aligned((x), (y)) +# define vectorscan_assume_aligned(x, y) __builtin_assume_aligned((x), (y)) # endif #else # ifdef HAVE_CC_BUILTIN_ASSUME_ALIGNED -# define assume_aligned(x, y) __builtin_assume_aligned((x), (y)) +# define vectorscan_assume_aligned(x, y) __builtin_assume_aligned((x), (y)) # endif #endif // Fallback to identity case. -#ifndef assume_aligned -#define assume_aligned(x, y) (x) +#ifndef vectorscan_assume_aligned +#define vectorscan_assume_aligned(x, y) (x) #endif template From dbdbfe947328a51d954b971171426b101da64012 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Tue, 21 Mar 2023 18:07:06 +0000 Subject: [PATCH 2/8] Set Ragel.rl char type to unsigned, #135 --- cmake/ragel.cmake | 2 +- src/hs.h | 2 +- src/parser/Parser.rl | 1 + src/parser/control_verbs.rl | 1 + tools/hscollider/ColliderCorporaParser.rl | 1 + util/ExpressionParser.rl | 1 + 6 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmake/ragel.cmake b/cmake/ragel.cmake index d3f0b9269..f33a96a14 100644 --- a/cmake/ragel.cmake +++ b/cmake/ragel.cmake @@ -7,7 +7,7 @@ function(ragelmaker src_rl) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${src_dir}/${src_file}.cpp COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${src_dir} - COMMAND ${RAGEL} ${CMAKE_CURRENT_SOURCE_DIR}/${src_rl} -o ${rl_out} + COMMAND ${RAGEL} ${CMAKE_CURRENT_SOURCE_DIR}/${src_rl} -o ${rl_out -G0} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${src_rl} ) add_custom_target(ragel_${src_file} DEPENDS ${rl_out}) diff --git a/src/hs.h b/src/hs.h index 2fe5d248b..cdc1ffbc9 100644 --- a/src/hs.h +++ b/src/hs.h @@ -43,7 +43,7 @@ #define HS_MAJOR 5 #define HS_MINOR 4 -#define HS_PATCH 0 +#define HS_PATCH 9 #include "hs_compile.h" #include "hs_runtime.h" diff --git a/src/parser/Parser.rl b/src/parser/Parser.rl index 0fa76aca3..b20065019 100644 --- a/src/parser/Parser.rl +++ b/src/parser/Parser.rl @@ -272,6 +272,7 @@ unichar readUtf8CodePoint4c(const char *s) { %%{ machine regex; + alphtype unsigned char; action throwUnsupportedEscape { ostringstream str; diff --git a/src/parser/control_verbs.rl b/src/parser/control_verbs.rl index 1d3e33a9a..09b0bfd7b 100644 --- a/src/parser/control_verbs.rl +++ b/src/parser/control_verbs.rl @@ -54,6 +54,7 @@ const char *read_control_verbs(const char *ptr, const char *end, size_t start, %%{ machine ControlVerbs; + alphtype unsigned char; # Verbs that we recognise but do not support. unhandledVerbs = '(*' ( diff --git a/tools/hscollider/ColliderCorporaParser.rl b/tools/hscollider/ColliderCorporaParser.rl index ab40b2ba3..04e8f6feb 100644 --- a/tools/hscollider/ColliderCorporaParser.rl +++ b/tools/hscollider/ColliderCorporaParser.rl @@ -57,6 +57,7 @@ char unhex(const char *start, UNUSED const char *end) { %%{ machine FileCorporaParser; + alphtype unsigned char; action accumulateNum { num = (num * 10) + (fc - '0'); diff --git a/util/ExpressionParser.rl b/util/ExpressionParser.rl index fec479229..b93f069d3 100644 --- a/util/ExpressionParser.rl +++ b/util/ExpressionParser.rl @@ -55,6 +55,7 @@ enum ParamKey { %%{ machine ExpressionParser; + alphtype unsigned char; action accumulateNum { num = (num * 10) + (fc - '0'); From 1ce45a31c50709f6c80048e28802e42432475465 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Tue, 21 Mar 2023 18:11:17 +0000 Subject: [PATCH 3/8] fix typo --- cmake/ragel.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/ragel.cmake b/cmake/ragel.cmake index f33a96a14..3697195b6 100644 --- a/cmake/ragel.cmake +++ b/cmake/ragel.cmake @@ -7,7 +7,7 @@ function(ragelmaker src_rl) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${src_dir}/${src_file}.cpp COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${src_dir} - COMMAND ${RAGEL} ${CMAKE_CURRENT_SOURCE_DIR}/${src_rl} -o ${rl_out -G0} + COMMAND ${RAGEL} ${CMAKE_CURRENT_SOURCE_DIR}/${src_rl} -o ${rl_out} -G0 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${src_rl} ) add_custom_target(ragel_${src_file} DEPENDS ${rl_out}) From 9f8758d2701de5d31183cc61d80ebe40a0529ff9 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Wed, 22 Mar 2023 08:49:19 +0000 Subject: [PATCH 4/8] Force -funsigned-char to RAGEL_C_FLAGS --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22af3c5cd..3d22d6ec7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -588,7 +588,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}") endif() -set(RAGEL_C_FLAGS "-Wno-unused") +set(RAGEL_C_FLAGS "-Wno-unused -funsigned-char") set_source_files_properties( ${CMAKE_BINARY_DIR}/src/parser/Parser.cpp From 101f6083b090c02d86a852df512e3291f4bf7594 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Wed, 22 Mar 2023 11:29:02 +0200 Subject: [PATCH 5/8] add -funsigned-char to RAGEL_C_FLAGS, move util build after that --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d22d6ec7..0451367c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -544,7 +544,6 @@ endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_CXX_FLAGS}") -add_subdirectory(util) add_subdirectory(doc/dev-reference) # PCRE check, we have a fixed requirement for PCRE to use Chimera @@ -604,6 +603,8 @@ set_source_files_properties( ragelmaker(src/parser/control_verbs.rl) +add_subdirectory(util) + SET(hs_HEADERS src/hs.h src/hs_common.h From 66289cdacf3910a0320952d54a8920250e53508a Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Wed, 22 Mar 2023 11:29:28 +0200 Subject: [PATCH 6/8] fix ExpressionParser.cpp path --- util/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index ea942ef1a..214da90cb 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -6,8 +6,10 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS} ${HS_CXX_FLAGS}") include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}) +message("RAGEL_C_FLAGS" ${RAGEL_C_FLAGS}) + set_source_files_properties( - ${CMAKE_BINARY_DIR}/tools/ExpressionParser.cpp + ${CMAKE_BINARY_DIR}/util/ExpressionParser.cpp PROPERTIES COMPILE_FLAGS "${RAGEL_C_FLAGS}") From 842e680650f8a74a0897c615c4c7fef102a7fb6b Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Wed, 22 Mar 2023 21:39:03 +0200 Subject: [PATCH 7/8] clang 14 makes some test failed because val is uninitialized --- src/fdr/teddy_runtime_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fdr/teddy_runtime_common.h b/src/fdr/teddy_runtime_common.h index b76800eb0..d27be994e 100644 --- a/src/fdr/teddy_runtime_common.h +++ b/src/fdr/teddy_runtime_common.h @@ -348,7 +348,7 @@ static really_inline m512 vectoredLoad512(m512 *p_mask, const u8 *ptr, const size_t start_offset, const u8 *lo, const u8 *hi, const u8 *hbuf, size_t hlen, const u32 nMasks) { - m512 val; + m512 val = zeroes512(); uintptr_t copy_start; uintptr_t copy_len; From eef3f06c94317248200e81b537d88182c8dcc190 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Thu, 23 Mar 2023 08:29:20 +0000 Subject: [PATCH 8/8] Bump version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0451367c3..e90d8c98d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project (vectorscan C CXX) set (HS_MAJOR_VERSION 5) set (HS_MINOR_VERSION 4) -set (HS_PATCH_VERSION 8) +set (HS_PATCH_VERSION 9) set (HS_VERSION ${HS_MAJOR_VERSION}.${HS_MINOR_VERSION}.${HS_PATCH_VERSION}) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)