Move FN_NOTE_AlwaysInline and other out of ParamAttrs namespace.
[oota-llvm.git] / lib / Transforms / IPO / InlineSimple.cpp
index d72edf84805ee0707f441ad504f95314823c7cc0..42897676418fa9d1803f89ebf5bcaa63d91dcd7f 100644 (file)
@@ -35,24 +35,39 @@ namespace {
     InlineCostAnalyzer CA;
   public:
     SimpleInliner() : Inliner(&ID) {}
+    SimpleInliner(int Threshold) : Inliner(&ID, Threshold) {}
     static char ID; // Pass identification, replacement for typeid
     int getInlineCost(CallSite CS) {
       return CA.getInlineCost(CS, NeverInline);
     }
+    float getInlineFudgeFactor(CallSite CS) {
+      return CA.getInlineFudgeFactor(CS);
+    }
     virtual bool doInitialization(CallGraph &CG);
   };
-  char SimpleInliner::ID = 0;
-  RegisterPass<SimpleInliner> X("inline", "Function Integration/Inlining");
 }
 
+char SimpleInliner::ID = 0;
+static RegisterPass<SimpleInliner>
+X("inline", "Function Integration/Inlining");
+
 Pass *llvm::createFunctionInliningPass() { return new SimpleInliner(); }
 
+Pass *llvm::createFunctionInliningPass(int Threshold) { 
+  return new SimpleInliner(Threshold);
+}
+
 // doInitialization - Initializes the vector of functions that have been
 // annotated with the noinline attribute.
 bool SimpleInliner::doInitialization(CallGraph &CG) {
   
   Module &M = CG.getModule();
   
+  for (Module::iterator I = M.begin(), E = M.end();
+       I != E; ++I)
+    if (!I->isDeclaration() && I->hasNote(FN_NOTE_NoInline))
+      NeverInline.insert(I);
+
   // Get llvm.noinline
   GlobalVariable *GV = M.getNamedGlobal("llvm.noinline");