[FunctionAttr] Infer nonnull attributes on returns
authorPhilip Reames <listmail@philipreames.com>
Mon, 31 Aug 2015 19:44:38 +0000 (19:44 +0000)
committerPhilip Reames <listmail@philipreames.com>
Mon, 31 Aug 2015 19:44:38 +0000 (19:44 +0000)
commitbf9ec6af4819a085acaf3d3c472776297bab569c
treed8b5a45f74774d2cbc554301959e568ed1b92ac3
parent19c43a6286235ba53cfff9a6669f5ec6c4825b5e
[FunctionAttr] Infer nonnull attributes on returns

Teach FunctionAttr to infer the nonnull attribute on return values of functions which never return a potentially null value. This is done both via a conservative local analysis for the function itself and a optimistic per-SCC analysis. If no function in the SCC returns anything which could be null (other than values from other functions in the SCC), we can conclude no function returned a null pointer. Even if some function within the SCC returns a null pointer, we may be able to locally conclude that some don't.

Differential Revision: http://reviews.llvm.org/D9688

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