[PATCH] D28204: [ValueTracking] use nonnull argument attribute to eliminate null checks

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 1 10:17:11 PST 2017


spatel added a comment.

In https://reviews.llvm.org/D28204#633198, @chandlerc wrote:

> Can you add a some negative tests showing that we don't eliminate null checks *before* a call?


Repurposed the 'caller4' test so that the null check comes before the call. I think this shows a missed opportunity to simplify the check, but let me know if I'm not seeing that correctly. Also, added a 'caller5' test where we can't simplify the check.

> Also would be good to test a subtle case but one I think is correct: when CtxtI is the call instruction with the nonnull. I'm imagining something like deducing nonnull for one argument from the attribute on another when the same pointer is passed to both. Not sure what transform pass to use but it seems a good case to document.

Added an instcombine test 'deduce_nonnull_from_another_call' that isn't quite what was suggested, but shows that the value tracking improvement affects an existing transform in InstCombiner::visitCallSite().

> Finally, before this goes in, I think we may need to do something to prevent worsening the bugs exposed by newer glibc marking memcpy and friends with nonnull....

If there are required changes for clang/llvm itself, I could use some hints about how to sniff those out. I found this mail from Aug 2015:
http://lists.llvm.org/pipermail/llvm-dev/2015-August/088950.html
and this commit:
https://reviews.llvm.org/rL243927
...we need to add more guard checks around memcpy() and other string.h functions?


https://reviews.llvm.org/D28204





More information about the llvm-commits mailing list