mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
replace --optimize-only with --optimize-funcs and --optimize-files
This commit is contained in:
parent
aa91f72b34
commit
9069e744f9
8 changed files with 176 additions and 125 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue