[FunctionAttrs] Move the malloc-like test to a static helper function

that could be used from a new pass manager. This one makes particular
sense as a static helper as it doesn't even need TLI.

llvm-svn: 247525
This commit is contained in:
Chandler Carruth 2015-09-13 08:23:27 +00:00
parent 8874b78697
commit 3824f859f5
1 changed files with 3 additions and 4 deletions

View File

@ -72,7 +72,6 @@ private:
bool AddReadAttrs(const CallGraphSCC &SCC);
bool AddArgumentAttrs(const CallGraphSCC &SCC);
bool IsFunctionMallocLike(Function *F, SmallPtrSet<Function *, 8> &) const;
bool AddNoAliasAttrs(const CallGraphSCC &SCC);
bool AddNonNullAttrs(const CallGraphSCC &SCC);
bool annotateLibraryCalls(const CallGraphSCC &SCC);
@ -682,8 +681,8 @@ bool FunctionAttrs::AddArgumentAttrs(const CallGraphSCC &SCC) {
///
/// A function is "malloc-like" if it returns either null or a pointer that
/// doesn't alias any other pointer visible to the caller.
bool FunctionAttrs::IsFunctionMallocLike(
Function *F, SmallPtrSet<Function *, 8> &SCCNodes) const {
static bool isFunctionMallocLike(Function *F,
SmallPtrSet<Function *, 8> &SCCNodes) {
SmallSetVector<Value *, 8> FlowsToReturn;
for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)
if (ReturnInst *Ret = dyn_cast<ReturnInst>(I->getTerminator()))
@ -777,7 +776,7 @@ bool FunctionAttrs::AddNoAliasAttrs(const CallGraphSCC &SCC) {
if (!F->getReturnType()->isPointerTy())
continue;
if (!IsFunctionMallocLike(F, SCCNodes))
if (!isFunctionMallocLike(F, SCCNodes))
return false;
}