Add support to ValueTracking for determining that a pointer is non-null
authorChandler Carruth <chandlerc@gmail.com>
Fri, 7 Dec 2012 02:08:58 +0000 (02:08 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 7 Dec 2012 02:08:58 +0000 (02:08 +0000)
commit80d3e56c738aea996510c5c4435a0aa7b90ccf6f
treebdfe72e494dc137e6bd825d105429fd57ee8d109
parente483d87bd93d1dc67784492e48e46135ec0b1b09
Add support to ValueTracking for determining that a pointer is non-null
by virtue of inbounds GEPs that preclude a null pointer.

This is a very common pattern in the code generated by std::vector and
other standard library routines which use allocators that test for null
pervasively. This is one step closer to teaching Clang+LLVM to be able
to produce an empty function for:

  void f() {
    std::vector<int> v;
    v.push_back(1);
    v.push_back(2);
    v.push_back(3);
    v.push_back(4);
  }

Which is related to getting them to completely fold SmallVector
push_back sequences into constants when inlining and other optimizations
make that a possibility.

llvm-svn: 169573
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstSimplify/compare.ll