From 848219ca612e5488982f23c37c7459aeedff77e3 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 13 Sep 2015 08:23:27 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247525 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/FunctionAttrs.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp index cfeedf6d1db..109ef16872a 100644 --- a/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/lib/Transforms/IPO/FunctionAttrs.cpp @@ -72,7 +72,6 @@ private: bool AddReadAttrs(const CallGraphSCC &SCC); bool AddArgumentAttrs(const CallGraphSCC &SCC); - bool IsFunctionMallocLike(Function *F, SmallPtrSet &) 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 &SCCNodes) const { +static bool isFunctionMallocLike(Function *F, + SmallPtrSet &SCCNodes) { SmallSetVector FlowsToReturn; for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) if (ReturnInst *Ret = dyn_cast(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; } -- 2.34.1