replace --optimize-only with --optimize-funcs and --optimize-files

This commit is contained in:
Vern Paxson 2021-12-10 12:45:27 -08:00
parent aa91f72b34
commit 9069e744f9
8 changed files with 176 additions and 125 deletions

View file

@ -107,19 +107,29 @@ void Inliner::Analyze()
}
for ( auto& f : funcs )
{
const auto& func_ptr = f.FuncPtr();
const auto& func = func_ptr.get();
const auto& body = f.Body();
// Candidates are non-event, non-hook, non-recursive,
// non-compiled functions ... that don't use lambdas or when's,
// since we don't currently compute the closures/frame
// sizes for them correctly, and more fundamentally since
// we don't compile them and hence inlining them will
// make the parent non-compilable.
if ( f.Func()->Flavor() == FUNC_FLAVOR_FUNCTION &&
non_recursive_funcs.count(f.Func()) > 0 && f.Profile()->NumLambdas() == 0 &&
f.Profile()->NumWhenStmts() == 0 && f.Body()->Tag() != STMT_CPP )
inline_ables.insert(f.Func());
if ( should_analyze(func_ptr, body) && func->Flavor() == FUNC_FLAVOR_FUNCTION &&
non_recursive_funcs.count(func) > 0 && f.Profile()->NumLambdas() == 0 &&
f.Profile()->NumWhenStmts() == 0 && body->Tag() != STMT_CPP )
inline_ables.insert(func);
}
for ( auto& f : funcs )
{
const auto& func_ptr = f.FuncPtr();
const auto& func = func_ptr.get();
const auto& body = f.Body();
// Processing optimization: only spend time trying to inline f
// if we haven't marked it as inlineable. This trades off a
// bunch of compilation load (inlining every single function,
@ -128,7 +138,8 @@ void Inliner::Analyze()
// circumstances in which a Zeek function can be called
// not ultimately stemming from an event (such as global
// scripting, or expiration functions).
if ( inline_ables.count(f.Func()) == 0 )
if ( should_analyze(func_ptr, body) && inline_ables.count(func) == 0 )
InlineFunction(&f);
}
}