[llvm-dev] Help me modify llvm optimizer to eliminate valgrind false positive?

Eyal Soha via llvm-dev llvm-dev at lists.llvm.org
Fri Feb 26 21:52:11 PST 2021


I spent a few days debugging a valgrind memcheck false positive that was
introduced by a new optimization in clang version 10.

Valgrind is mistakenly reporting an error due to the way that clang 10 is
emitting asm.  But it's a trivial matter to fix the code.  I just needed to
change this:

  401697:       66 0f 6e d2             movd   %edx,%xmm2
  40169b:       66 0f 60 d2             punpcklbw %xmm2,%xmm2
  40169f:       66 0f 61 da             punpcklwd %xmm2,%xmm3

to this:

  4016a3:       66 0f 6e da             movd   %edx,%xmm3
  4016a7:       66 0f 60 db             punpcklbw %xmm3,%xmm3
  4016ab:       66 0f 61 db             punpcklwd %xmm3,%xmm3

So instead of using $xmm2 and then $xmm3 just use $xmm3.  This was a tiny
change and I was able to modify the executable to do it.

Is it possible to modify clang/llvm to do this where possible?  Valgrind is
a popular tool for finding bugs in code and if it's not too much trouble
for llvm and there's no performance penalty, maybe LLVM could accommodate?

I'm willing to do the work but I'm not sure where to start.help but I'm not
sure where to start.

There are more details about the issue in the Valgrind bug report:
https://bugs.kde.org/show_bug.cgi?id=432801#c12

Thanks for your help!

Eyal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210226/88d460b8/attachment.html>


More information about the llvm-dev mailing list