Move duplicated code into a helper function (exposed through overload).
[oota-llvm.git] / lib / Transforms / IPO / InlineSimple.cpp
index eecd9b103086dd96c652b7d8a08470e7807da00b..e5f46d7a7837dc142d57c0bb7617b79eeaa639d2 100644 (file)
@@ -56,6 +56,17 @@ public:
   void getAnalysisUsage(AnalysisUsage &AU) const override;
 };
 
+static int computeThresholdFromOptLevels(unsigned OptLevel,
+                                         unsigned SizeOptLevel) {
+  if (OptLevel > 2)
+    return 275;
+  if (SizeOptLevel == 1)
+    return 75;
+  if (SizeOptLevel == 2)
+    return 25;
+  return 225;
+}
+
 } // end anonymous namespace
 
 char SimpleInliner::ID = 0;
@@ -72,6 +83,12 @@ Pass *llvm::createFunctionInliningPass(int Threshold) {
   return new SimpleInliner(Threshold);
 }
 
+Pass *llvm::createFunctionInliningPass(unsigned OptLevel,
+                                       unsigned SizeOptLevel) {
+  return new SimpleInliner(
+      computeThresholdFromOptLevels(OptLevel, SizeOptLevel));
+}
+
 bool SimpleInliner::runOnSCC(CallGraphSCC &SCC) {
   ICA = &getAnalysis<InlineCostAnalysis>();
   return Inliner::runOnSCC(SCC);