From: Andreas Arnez Date: Mon, 2 Mar 2020 15:22:59 +0000 (+0100) Subject: Bug 418435 - s390x: Avoid extra value dependency in CLC implementation X-Git-Tag: VALGRIND_3_16_0~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91bf2d2d8cbf5942d73dc748150945a5c24ecae2;p=thirdparty%2Fvalgrind.git Bug 418435 - s390x: Avoid extra value dependency in CLC implementation 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. --- diff --git a/NEWS b/NEWS index d305c833eb..d8095be464 100644 --- 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) diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c index eb3a25b567..c27a8d3fe6 100644 --- a/VEX/priv/guest_s390_toIR.c +++ b/VEX/priv/guest_s390_toIR.c @@ -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