[ThinLTO] Remove stale comment (NFC)
[oota-llvm.git] / lib / Transforms / IPO / FunctionImport.cpp
index 1f88da5e12ac6fdd3c0da56f330a0884eddb69f4..345b2f540adfc4658226ee158bfafbb25e741d37 100644 (file)
@@ -28,6 +28,11 @@ using namespace llvm;
 
 #define DEBUG_TYPE "function-import"
 
+/// Limit on instruction count of imported functions.
+static cl::opt<unsigned> ImportInstrLimit(
+    "import-instr-limit", cl::init(100), cl::Hidden, cl::value_desc("N"),
+    cl::desc("Only import functions with less than N instructions"));
+
 // Load lazily a module from \p FileName in \p Context.
 static std::unique_ptr<Module> loadFile(const std::string &FileName,
                                         LLVMContext &Context) {
@@ -124,9 +129,12 @@ bool FunctionImporter::importFunctions(Module &M) {
       llvm_unreachable("Missing summary");
     }
 
-    //
-    // No profitability notion right now, just import all the time...
-    //
+    if (Summary->instCount() > ImportInstrLimit) {
+      dbgs() << "Skip import of " << CalledFunctionName << " with "
+             << Summary->instCount() << " instructions (limit "
+             << ImportInstrLimit << ")\n";
+      continue;
+    }
 
     // Get the module path from the summary.
     auto FileName = Summary->modulePath();