]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 418435 - s390x: Avoid extra value dependency in CLC implementation
authorAndreas Arnez <arnez@linux.ibm.com>
Mon, 2 Mar 2020 15:22:59 +0000 (16:22 +0100)
committerAndreas Arnez <arnez@linux.ibm.com>
Wed, 4 Mar 2020 17:23:04 +0000 (18:23 +0100)
The test memcheck/tests/memcmp currently fails on s390x because it yields
the expected "conditional jump or move depends on uninitialised value(s)"
message twice instead of just once.

This is caused by the handling of the s390x instruction CLC, see
s390_irgen_CLC_EX().  When comparing two bytes from the two input strings,
the implementation uses the comparison result for a conditional branch to
the next instruction.  But if no further bytes need to be compared, the
comparison result is also used for generating the resulting condition
code.

There are two cases: Either the inputs are equal; then the resulting
condition code is zero.  This is what happens in the memcmp test case.  Or
the inputs are different; then the resulting condition code is 1 or 2 if
the first or second operand is greater, respectively.

At least in the first case it is easy to avoid the additional dependency,
by clearing the condition code explicitly.  Just do this.

NEWS
VEX/priv/guest_s390_toIR.c

diff --git a/NEWS b/NEWS
index d305c833eb925b81859f76ad23f1f0f426339bae..d8095be46443bcfaea404fcc53bccc13a9ec6bb3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -129,6 +129,7 @@ n-i-bz  Fix non-glibc build of test suite with s390x_features
 417452  s390_insn_store_emit: dst->tag for HRcVec128
 417578  Add suppressions for glibc DTV leaks
 417906  clone with CLONE_VFORK and no CLONE_VM fails
+418435  s390x: memcmp test yields extra "Conditional jump or move depends on uninitialised value(s)"
 
 
 Release 3.15.0 (12 April 2019)
index eb3a25b56736f1d5ef97bb86eb3bcd2cacc770e9..c27a8d3fe61bc4cb8ac19a8396f88b5e9b51acfb 100644 (file)
@@ -12840,6 +12840,9 @@ s390_irgen_CLC_EX(IRTemp length, IRTemp start1, IRTemp start2)
    put_counter_dw0(binop(Iop_Add64, mkexpr(counter), mkU64(1)));
    iterate_if(binop(Iop_CmpNE64, mkexpr(counter), mkexpr(length)));
    put_counter_dw0(mkU64(0));
+
+   /* Equal.  Clear CC, to avoid duplicate dependency on the comparison. */
+   s390_cc_set_val(0);
 }
 
 static void