diff --git a/interpreter/cling/lib/Interpreter/BackendPasses.cpp b/interpreter/cling/lib/Interpreter/BackendPasses.cpp index 74b246a5f6d5dce4da4390998b7913fee8bc0b77..2282019dec1e45c13cd525d72cc92e7452bfcd7e 100644 --- a/interpreter/cling/lib/Interpreter/BackendPasses.cpp +++ b/interpreter/cling/lib/Interpreter/BackendPasses.cpp @@ -267,6 +267,15 @@ namespace { // GV is a definition. + if (auto *Func = dyn_cast<Function>(&GV)) + if (Func->getInstructionCount() < 50) { + // This is a small function. Keep its definition to retain it for + // inlining: the cost for JITting it is small, and the likelihood + // that the call will be inlined is high. + return false; + } + + llvm::GlobalValue::LinkageTypes LT = GV.getLinkage(); if (!GV.isDiscardableIfUnused(LT) || !GV.isWeakForLinker(LT)) return false;