1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 12:02:58 +02:00

[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 55bf36b635
commit bcbc41fdb2

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;
}