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

Akira Hatanaka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 12 23:59:29 PST 2017


ahatanak 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);
----------------
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. 


https://reviews.llvm.org/D28494





More information about the llvm-commits mailing list