#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) {
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();