From 5c4be3f11c38f83c814b685994d4f428baa30fb6 Mon Sep 17 00:00:00 2001 From: Martin Cermak Date: Tue, 4 Aug 2026 10:05:14 +0200 Subject: [PATCH] Handle the sse4-x86 test correctly when Valgrind compiled with Clang The none/tests/x86/sse4-x86 fails when valgrind is compiled with clang. With default clang -O2 (which involves the slp-vectorizer optimization) this test code translates to assembly involving MOVDQA. That's a SIMD instruction requiring explicitly aligned memory. Turns out that the required 16-byte stack alignment isn't in place by default. This instruction ends up with a GP, so that Valgrind ends up with segmentation fault. To fix this, the affected clean helper function g_calc_mpsadbw() is now compiled with the 'force_align_arg_pointer' attribute, making sure the needed stack alignment is in place. Both GCC and clang accept this attribute. https://bugs.kde.org/show_bug.cgi?id=523626 --- NEWS | 1 + VEX/priv/guest_generic_helpers.h | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index cb4f4f1d8..681863076 100644 --- a/NEWS +++ b/NEWS @@ -54,6 +54,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 522160 Robustify the flags check in the none/tests/x86/crc32 test 522533 Valgrind can't handle some encoding from gas trunk with -Wa,-O2 523375 Fix none/tests/amd64/pcmpxstrx64.c +523626 Fix sse4-x86 test fails when valgrind compiled with clang To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/VEX/priv/guest_generic_helpers.h b/VEX/priv/guest_generic_helpers.h index 3584b7c2d..84b50c146 100644 --- a/VEX/priv/guest_generic_helpers.h +++ b/VEX/priv/guest_generic_helpers.h @@ -116,9 +116,13 @@ static inline ULong sad_8x4 ( ULong xx, ULong yy ) } /* CALLED FROM GENERATED CODE: CLEAN HELPER */ -static inline ULong g_calc_mpsadbw ( ULong sHi, ULong sLo, - ULong dHi, ULong dLo, - ULong imm_and_return_control_bit ) +#if defined(VGA_x86) +// Handle https://bugs.kde.org/show_bug.cgi?id=523626 +__attribute__((force_align_arg_pointer)) +#endif +static ULong g_calc_mpsadbw ( ULong sHi, ULong sLo, + ULong dHi, ULong dLo, + ULong imm_and_return_control_bit ) { UInt imm8 = imm_and_return_control_bit & 7; Bool calcHi = (imm_and_return_control_bit >> 7) & 1; -- 2.47.3