]> granicus.if.org Git - llvm/commit
[CaptureTracking] Don't let comparisons against null escape inbounds pointers
authorAyke van Laethem <aykevanlaethem@gmail.com>
Sun, 9 Jun 2019 10:20:33 +0000 (10:20 +0000)
committerAyke van Laethem <aykevanlaethem@gmail.com>
Sun, 9 Jun 2019 10:20:33 +0000 (10:20 +0000)
commit1cbbb3f527a5aa13eda990e3dfa31f2ca4f64e07
treed354769ca989293b415190f60da2bda2180b84bb
parentd1edfbfdf21e844c2cc7c3cb7e5dc89da5539f94
[CaptureTracking] Don't let comparisons against null escape inbounds pointers

Pointers that are in-bounds (either through dereferenceable_or_null or
thorough a getelementptr inbounds) cannot be captured with a comparison
against null. There is no way to construct a pointer that is still in
bounds but also NULL.

This helps safe languages that insert null checks before load/store
instructions. Without this patch, almost all pointers would be
considered captured even for simple loads. With this patch, an icmp with
null will not be seen as escaping as long as certain conditions are met.

There was a lot of discussion about this patch. See the Phabricator
thread for detals.

Differential Revision: https://reviews.llvm.org/D60047

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362900 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/CaptureTracking.cpp
test/Transforms/FunctionAttrs/nocapture.ll