Add a clear() method to PriorityQueue.
[oota-llvm.git] / lib / Transforms / IPO / Inliner.cpp
index 13739a5ea288437516c48ae6513f9a99bce6ac55..1c3d5a81f36967a49c58398a2d0be62ae93a8f07 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -30,15 +30,16 @@ using namespace llvm;
 STATISTIC(NumInlined, "Number of functions inlined");
 STATISTIC(NumDeleted, "Number of functions deleted because all callers found");
 
-namespace {
-  cl::opt<unsigned>             // FIXME: 200 is VERY conservative
-  InlineLimit("inline-threshold", cl::Hidden, cl::init(200),
+static cl::opt<int>
+InlineLimit("inline-threshold", cl::Hidden, cl::init(200),
         cl::desc("Control the amount of inlining to perform (default = 200)"));
-}
 
 Inliner::Inliner(const void *ID) 
   : CallGraphSCCPass((intptr_t)ID), InlineThreshold(InlineLimit) {}
 
+Inliner::Inliner(const void *ID, int Threshold) 
+  : CallGraphSCCPass((intptr_t)ID), InlineThreshold(Threshold) {}
+
 /// getAnalysisUsage - For this class, we declare that we require and preserve
 /// the call graph.  If the derived class implements this method, it should
 /// always explicitly call the implementation here.
@@ -137,7 +138,9 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
         // try to do so.
         CallSite CS = CallSites[CSi];
         int InlineCost = getInlineCost(CS);
-        if (InlineCost >= (int)InlineThreshold) {
+        float FudgeFactor = getInlineFudgeFactor(CS);
+
+        if (InlineCost >= (int)(InlineThreshold * FudgeFactor)) {
           DOUT << "    NOT Inlining: cost=" << InlineCost
                << ", Call: " << *CS.getInstruction();
         } else {