[PATCH] D28494: Make `@llvm.objectsize` more conservative with null pointers.

George Burgess IV via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 11:28:56 PST 2017

george.burgess.iv added inline comments.

Comment at: lib/Analysis/MemoryBuiltins.cpp:439
+    if (ValueIsFromNull && NullIsUnknownSize)
+      return ConstantInt::get(ResultType, MaxVal ? -1ULL : 0);
     return ConstantInt::get(ResultType, Size);
ahatanak wrote:
> Is there a possibility that, when NullIsUnknownSize=true and MustSucceed=false, returning a ConstantInt instead of a nullptr can cause InstCombine to prematurely optimize away objectsize?
> I'm thinking about a case where the first operand of objectsize is "select %cmp, null, %someptr". If %cmp turns out to be false later and the size of the object "%someptr" points to is known, objectsize can be replaced with the exact size of the object. 
Good point. I rewrote this to just return `unknown`, then. :)


More information about the llvm-commits mailing list