[FunctionAttrs] Make the per-function attribute inference a boring
authorChandler Carruth <chandlerc@gmail.com>
Sun, 13 Sep 2015 08:03:23 +0000 (08:03 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sun, 13 Sep 2015 08:03:23 +0000 (08:03 +0000)
static function rather than a method. It just needed access to
TargetLibraryInfo, and this way it can be easily reused between the
current FunctionAttrs implementation and any port for the new pass
manager.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247522 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/FunctionAttrs.cpp

index 30c0b3a1763300d533698c5a6beade3cc8d22361..3ea54687365c1fb44c6a85eccdc60ad33e70079b 100644 (file)
@@ -77,7 +77,6 @@ private:
   bool ReturnsNonNull(Function *F, SmallPtrSet<Function *, 8> &,
                       bool &Speculative) const;
   bool AddNonNullAttrs(const CallGraphSCC &SCC);
   bool ReturnsNonNull(Function *F, SmallPtrSet<Function *, 8> &,
                       bool &Speculative) const;
   bool AddNonNullAttrs(const CallGraphSCC &SCC);
-  bool inferPrototypeAttributes(Function &F);
   bool annotateLibraryCalls(const CallGraphSCC &SCC);
 };
 }
   bool annotateLibraryCalls(const CallGraphSCC &SCC);
 };
 }
@@ -983,13 +982,13 @@ static void setDoesNotAlias(Function &F, unsigned n) {
 /// attributes.
 ///
 /// Returns true if any attributes were set and false otherwise.
 /// attributes.
 ///
 /// Returns true if any attributes were set and false otherwise.
-bool FunctionAttrs::inferPrototypeAttributes(Function &F) {
+static bool inferPrototypeAttributes(Function &F, const TargetLibraryInfo &TLI) {
   if (F.hasFnAttribute(Attribute::OptimizeNone))
     return false;
 
   FunctionType *FTy = F.getFunctionType();
   LibFunc::Func TheLibFunc;
   if (F.hasFnAttribute(Attribute::OptimizeNone))
     return false;
 
   FunctionType *FTy = F.getFunctionType();
   LibFunc::Func TheLibFunc;
-  if (!(TLI->getLibFunc(F.getName(), TheLibFunc) && TLI->has(TheLibFunc)))
+  if (!(TLI.getLibFunc(F.getName(), TheLibFunc) && TLI.has(TheLibFunc)))
     return false;
 
   switch (TheLibFunc) {
     return false;
 
   switch (TheLibFunc) {
@@ -1792,7 +1791,7 @@ bool FunctionAttrs::annotateLibraryCalls(const CallGraphSCC &SCC) {
     Function *F = (*I)->getFunction();
 
     if (F && F->isDeclaration())
     Function *F = (*I)->getFunction();
 
     if (F && F->isDeclaration())
-      MadeChange |= inferPrototypeAttributes(*F);
+      MadeChange |= inferPrototypeAttributes(*F, *TLI);
   }
 
   return MadeChange;
   }
 
   return MadeChange;