From ef66877e9e6db22cf273230e6b07840cf9373857 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Fri, 16 Sep 2022 12:41:08 +0300 Subject: [PATCH 1/7] [VSX] clang complains about the order of __vector --- src/util/supervector/arch/ppc64el/impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/supervector/arch/ppc64el/impl.cpp b/src/util/supervector/arch/ppc64el/impl.cpp index 2eba69b2..295cd128 100644 --- a/src/util/supervector/arch/ppc64el/impl.cpp +++ b/src/util/supervector/arch/ppc64el/impl.cpp @@ -49,7 +49,7 @@ really_inline SuperVector<16>::SuperVector(SuperVector const &other) template<> template<> -really_inline SuperVector<16>::SuperVector(char __bool __vector v) +really_inline SuperVector<16>::SuperVector(__vector __bool char v) { u.u8x16[0] = (uint8x16_t) v; }; From 3fc6c8a53273f29a01bdcd2e7d5e3d441371dbbc Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Fri, 16 Sep 2022 12:50:33 +0300 Subject: [PATCH 2/7] [VSX] movemask needs to be explicitly aligned on clang for vec_ste --- src/util/arch/ppc64el/simd_utils.h | 34 +++++++++++----------- src/util/supervector/arch/ppc64el/impl.cpp | 4 +-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/util/arch/ppc64el/simd_utils.h b/src/util/arch/ppc64el/simd_utils.h index ea1766b2..119d0946 100644 --- a/src/util/arch/ppc64el/simd_utils.h +++ b/src/util/arch/ppc64el/simd_utils.h @@ -152,7 +152,7 @@ static really_inline u32 movemask128(m128 a) { static uint8x16_t perm = { 16, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint8x16_t bitmask = vec_gb((uint8x16_t) a); bitmask = (uint8x16_t) vec_perm(vec_splat_u8(0), bitmask, perm); - u32 movemask; + u32 ALIGN_ATTR(16) movemask; vec_ste((uint32x4_t) bitmask, 0, &movemask); return movemask; } @@ -285,27 +285,27 @@ m128 loadbytes128(const void *ptr, unsigned int n) { return a; } -#define CASE_ALIGN_VECTORS(a, b, offset) case offset: return (m128)vec_sld((int8x16_t)(b), (int8x16_t)(a), (16 - offset)); break; +#define CASE_ALIGN_VECTORS(a, b, offset) case offset: return (m128)vec_sld((int8x16_t)(a), (int8x16_t)(b), (16 - offset)); break; static really_really_inline m128 palignr_imm(m128 r, m128 l, int offset) { switch (offset) { case 0: return l; break; - CASE_ALIGN_VECTORS(l, r, 1); - CASE_ALIGN_VECTORS(l, r, 2); - CASE_ALIGN_VECTORS(l, r, 3); - CASE_ALIGN_VECTORS(l, r, 4); - CASE_ALIGN_VECTORS(l, r, 5); - CASE_ALIGN_VECTORS(l, r, 6); - CASE_ALIGN_VECTORS(l, r, 7); - CASE_ALIGN_VECTORS(l, r, 8); - CASE_ALIGN_VECTORS(l, r, 9); - CASE_ALIGN_VECTORS(l, r, 10); - CASE_ALIGN_VECTORS(l, r, 11); - CASE_ALIGN_VECTORS(l, r, 12); - CASE_ALIGN_VECTORS(l, r, 13); - CASE_ALIGN_VECTORS(l, r, 14); - CASE_ALIGN_VECTORS(l, r, 15); + CASE_ALIGN_VECTORS(r, l, 1); + CASE_ALIGN_VECTORS(r, l, 2); + CASE_ALIGN_VECTORS(r, l, 3); + CASE_ALIGN_VECTORS(r, l, 4); + CASE_ALIGN_VECTORS(r, l, 5); + CASE_ALIGN_VECTORS(r, l, 6); + CASE_ALIGN_VECTORS(r, l, 7); + CASE_ALIGN_VECTORS(r, l, 8); + CASE_ALIGN_VECTORS(r, l, 9); + CASE_ALIGN_VECTORS(r, l, 10); + CASE_ALIGN_VECTORS(r, l, 11); + CASE_ALIGN_VECTORS(r, l, 12); + CASE_ALIGN_VECTORS(r, l, 13); + CASE_ALIGN_VECTORS(r, l, 14); + CASE_ALIGN_VECTORS(r, l, 15); case 16: return r; break; default: return zeroes128(); break; } diff --git a/src/util/supervector/arch/ppc64el/impl.cpp b/src/util/supervector/arch/ppc64el/impl.cpp index 295cd128..494bcbd6 100644 --- a/src/util/supervector/arch/ppc64el/impl.cpp +++ b/src/util/supervector/arch/ppc64el/impl.cpp @@ -269,10 +269,10 @@ really_inline SuperVector<16> SuperVector<16>::eq(SuperVector<16> const &b) cons template <> really_inline typename SuperVector<16>::comparemask_type SuperVector<16>::comparemask(void) const { - uint8x16_t bitmask = vec_gb( u.u8x16[0]); static uint8x16_t perm = { 16, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + uint8x16_t bitmask = vec_gb(u.u8x16[0]); bitmask = (uint8x16_t) vec_perm(vec_splat_u8(0), bitmask, perm); - u32 movemask; + u32 ALIGN_ATTR(16) movemask; vec_ste((uint32x4_t) bitmask, 0, &movemask); return movemask; } From 6de45b464879b8126f98d42526e0fabb870e7e91 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Fri, 16 Sep 2022 14:02:26 +0300 Subject: [PATCH 3/7] clang 14 complains about this, needs investigation --- src/rose/rose_build_add.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rose/rose_build_add.cpp b/src/rose/rose_build_add.cpp index dc9ee308..82f0e2e0 100644 --- a/src/rose/rose_build_add.cpp +++ b/src/rose/rose_build_add.cpp @@ -216,9 +216,9 @@ RoseRoleHistory selectHistory(const RoseBuildImpl &tbi, const RoseBuildData &bd, const bool fixed_offset_src = g[u].fixedOffset(); const bool has_bounds = g[e].minBound || (g[e].maxBound != ROSE_BOUND_INF); - DEBUG_PRINTF("edge %zu->%zu, bounds=[%u,%u], fixed_u=%d, prefix=%d\n", + /*DEBUG_PRINTF("edge %zu->%zu, bounds=[%u,%u], fixed_u=%d, prefix=%d\n", g[u].index, g[v].index, g[e].minBound, g[e].maxBound, - (int)g[u].fixedOffset(), (int)g[v].left); + (int)g[u].fixedOffset(), (int)g[v].left);*/ if (g[v].left) { // Roles with prefix engines have their history handled by that prefix. From 0e0147ec5c138c51673c7ddbfe3af88d852bbc33 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Fri, 16 Sep 2022 14:02:53 +0300 Subject: [PATCH 4/7] clang 14 does not allow bitwise OR for bools --- src/nfagraph/ng_misc_opt.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/nfagraph/ng_misc_opt.cpp b/src/nfagraph/ng_misc_opt.cpp index d0f1f029..2b898cf7 100644 --- a/src/nfagraph/ng_misc_opt.cpp +++ b/src/nfagraph/ng_misc_opt.cpp @@ -385,8 +385,7 @@ bool improveGraph(NGHolder &g, som_type som) { const vector ordering = getTopoOrdering(g); - return enlargeCyclicCR(g, som, ordering) - | enlargeCyclicCR_rev(g, ordering); + return enlargeCyclicCR(g, som, ordering) || enlargeCyclicCR_rev(g, ordering); } /** finds a smaller reachability for a state by the reverse transformation of From a4972aa191ed8664c39e4fcc626e3ee66cbea4ca Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Fri, 16 Sep 2022 14:03:17 +0300 Subject: [PATCH 5/7] remove leftover debug print --- src/util/supervector/arch/x86/impl.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/util/supervector/arch/x86/impl.cpp b/src/util/supervector/arch/x86/impl.cpp index c9daf0cf..49fbee99 100644 --- a/src/util/supervector/arch/x86/impl.cpp +++ b/src/util/supervector/arch/x86/impl.cpp @@ -523,9 +523,7 @@ template <> really_inline SuperVector<16> SuperVector<16>::loadu_maskz(void const *ptr, uint8_t const len) { SuperVector mask = Ones_vshr(16 -len); - mask.print8("mask"); SuperVector v = _mm_loadu_si128((const m128 *)ptr); - v.print8("v"); return mask & v; } From 911a98d54f974fc9e80879b6859a3748df4efc86 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Fri, 16 Sep 2022 14:04:59 +0300 Subject: [PATCH 6/7] clang 13+ gives wrong -Wunused-but-set-variable error on nfa/mcclellancompile.cpp about total_daddy variable, disabling --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57e986c9..5076f0a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ -cmake_minimum_required (VERSION 2.8.11) +cmake_minimum_required (VERSION 2.8.12) + project (vectorscan C CXX) set (HS_MAJOR_VERSION 5) @@ -296,6 +297,12 @@ if (NOT RELEASE_BUILD) # release builds set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Werror") set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Werror") + if (CMAKE_COMPILER_IS_CLANG) + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER "13.0") + set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-unused-but-set-variable") + set(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -Wno-unused-but-set-variable") + endif() + endif() endif() if (DISABLE_ASSERTS) From 48105cdd1de8b596f2c83dac6ad68741d3f6e7a4 Mon Sep 17 00:00:00 2001 From: Konstantinos Margaritis Date: Fri, 16 Sep 2022 14:05:31 +0300 Subject: [PATCH 7/7] move variable --- src/nfa/mcclellancompile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nfa/mcclellancompile.cpp b/src/nfa/mcclellancompile.cpp index 055920b2..d1afcbcc 100644 --- a/src/nfa/mcclellancompile.cpp +++ b/src/nfa/mcclellancompile.cpp @@ -1484,12 +1484,12 @@ bytecode_ptr mcclellanCompile_i(raw_dfa &raw, accel_dfa_build_strat &strat, find_wide_state(info); } - u16 total_daddy = 0; bool any_cyclic_near_anchored_state = is_cyclic_near(raw, raw.start_anchored); // Sherman optimization if (info.impl_alpha_size > 16) { + u16 total_daddy = 0; for (u32 i = 0; i < info.size(); i++) { if (info.is_widestate(i)) { continue;