From: Chandler Carruth Date: Sun, 13 Sep 2015 08:23:27 +0000 (+0000) Subject: [FunctionAttrs] Move the malloc-like test to a static helper function X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=848219ca612e5488982f23c37c7459aeedff77e3;hp=1f97273f8fb2e51080ef2c7a9cd867d0d0ccf8a0 [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 --- 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; }