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

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 13:34:52 PST 2016

efriedma 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())
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.


More information about the llvm-commits mailing list