[PATCH] D27855: [InstCombine] try to extend nonnull-ness of arguments from a callsite back to its parent function

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 17:10:34 PST 2016


spatel added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:2799
+  Instruction *Call = CS.getInstruction();
+  auto CallDominatesOtherUsesOfValue = [&Call, &DT](Value *V) {
+    for (User *U : V->users())
----------------
efriedma wrote:
> I don't think this check is sufficient; consider something like this:
> 
> ```
> void g(int* NONNULL notnull_ptr);
> void f(int *ptr, bool ptr_is_nonnull) {
>   if (ptr_is_nonnull) g(ptr);
> }
> ```
> 
> I think your check marks the "ptr" argument to f() as nonnull.  This deduction gets propagated out to callers of f(), which then assume the pointer isn't null.
Nice catch. Yes, that would be wrong. We can only do this if the callsite is in the entry block?


https://reviews.llvm.org/D27855





More information about the llvm-commits mailing list