]> granicus.if.org Git - llvm/commit
[msan] Fix PR32842
authorAlexander Potapenko <glider@google.com>
Thu, 11 May 2017 11:07:48 +0000 (11:07 +0000)
committerAlexander Potapenko <glider@google.com>
Thu, 11 May 2017 11:07:48 +0000 (11:07 +0000)
commita0d77192f69d829915c27d19de52ce35ca28ce4b
tree27e4e5b51e27725a20fe8ab7481e29de581fa673
parentc4b356568be61b998a4dd1da13b14a4d075be33c
[msan] Fix PR32842

It turned out that MSan was incorrectly calculating the shadow for int comparisons: it was done by truncating the result of (Shadow1 OR Shadow2) to i1, effectively rendering all bits except LSB useless.
This approach doesn't work e.g. in the case where the values being compared are even (i.e. have the LSB of the shadow equal to zero).
Instead, if CreateShadowCast() has to cast a bigger int to i1, we replace the truncation with an ICMP to 0.

This patch doesn't affect the code generated for SPEC 2006 binaries, i.e. there's no performance impact.

For the test case reported in PR32842 MSan with the patch generates a slightly more efficient code:

  orq     %rcx, %rax
  jne     .LBB0_6
, instead of:

  orl     %ecx, %eax
  testb   $1, %al
  jne     .LBB0_6

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302787 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Instrumentation/MemorySanitizer.cpp
test/Instrumentation/MemorySanitizer/pr32842.ll [new file with mode: 0644]