]> git.ipfire.org Git - thirdparty/valgrind.git/commit
s390x: Fix memcheck false positives with certain comparisons
authorAndreas Arnez <arnez@linux.ibm.com>
Tue, 16 May 2023 18:29:33 +0000 (20:29 +0200)
committerAndreas Arnez <arnez@linux.ibm.com>
Thu, 19 Oct 2023 10:36:16 +0000 (12:36 +0200)
commit7cf98163adb3f0d9dad28ad952325e91955811a4
tree6c6f202435ca048737a6bceb79669a55899b8587
parent2c874abbe3bc69d318685e072364e9c1b1f45a23
s390x: Fix memcheck false positives with certain comparisons

Consider this structure definition:

  struct s {
    unsigned b : 1;
    unsigned c : 1;
  } x;

Then certain compiler optimizations for a big-endian system may transform
the test

  if (x.b || x.c)
     ...

into a comparison `> 0x3f' of the structure's first byte.  Indeed, the
result of this comparison only depends on the two highest bits of the
byte.  Thus, even if the lower bits are undefined, memcheck shouldn't
complain, but it does.

For certain cases this can be fixed.  Do this by detecting comparisons
like this in the condition code helper for S390_CC_OP_UNSIGNED_COMPARE and
transforming them to a test for the selected bits instead.  Add a small
test to verify the fix.
VEX/priv/guest_s390_helpers.c
memcheck/tests/s390x/Makefile.am
memcheck/tests/s390x/cli.c [new file with mode: 0644]
memcheck/tests/s390x/cli.stderr.exp [new file with mode: 0644]
memcheck/tests/s390x/cli.stdout.exp [new file with mode: 0644]
memcheck/tests/s390x/cli.vgtest [new file with mode: 0644]