]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Handle the sse4-x86 test correctly when Valgrind compiled with Clang master
authorMartin Cermak <mcermak@redhat.com>
Tue, 4 Aug 2026 08:05:14 +0000 (10:05 +0200)
committerMartin Cermak <mcermak@redhat.com>
Tue, 4 Aug 2026 08:34:15 +0000 (10:34 +0200)
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
VEX/priv/guest_generic_helpers.h

diff --git a/NEWS b/NEWS
index cb4f4f1d8ed6b3e528f08eb191f25aa03ccd9fa8..68186307636f42f16b377b2a14933d78ae034ecc 100644 (file)
--- 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
index 3584b7c2db63b255023df9edf7c731ecbbeebfc2..84b50c1461f21ce78d4ba398886de3f4928eb46d 100644 (file)
@@ -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;