diff --git a/llvm/lib/Analysis/CFLGraph.h b/llvm/lib/Analysis/CFLGraph.h --- a/llvm/lib/Analysis/CFLGraph.h +++ b/llvm/lib/Analysis/CFLGraph.h @@ -429,12 +429,10 @@ if (Call.getType()->isPointerTy()) addNode(&Call); - // Check if Inst is a call to a library function that - // allocates/deallocates on the heap. Those kinds of functions do not - // introduce any aliases. - // TODO: address other common library functions such as realloc(), - // strdup(), etc. - if (isMallocOrCallocLikeFn(&Call, &TLI) || isFreeCall(&Call, &TLI)) + // Check if Inst is a call to a function that is annotated noalias + // (including allocation functions) or a library function that frees + // memory. Those kinds of functions do not introduce any aliases. + if (isNoAliasCall(&Call) || isFreeCall(&Call, &TLI)) return; // TODO: Add support for noalias args/all the other fun function @@ -461,11 +459,11 @@ } if (Call.getType()->isPointerTy()) { - auto *Fn = Call.getCalledFunction(); - if (Fn == nullptr || !Fn->returnDoesNotAlias()) - // No need to call addNode() since we've added Inst at the - // beginning of this function and we know it is not a global. - Graph.addAttr(InstantiatedValue{&Call, 0}, getAttrUnknown()); + // Since we checked isNoAliasCall and returned early if true, we don't + // need to confirm that it is false now. + // No need to call addNode() since we've added Inst at the + // beginning of this function and we know it is not a global. + Graph.addAttr(InstantiatedValue{&Call, 0}, getAttrUnknown()); } }