mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
fixes for correctly tracking which functions have been fully inlined
This commit is contained in:
parent
91d70e6dd4
commit
3f64858335
3 changed files with 17 additions and 7 deletions
|
@ -218,6 +218,8 @@ ExprPtr Inliner::CheckForInlining(CallExprPtr c)
|
|||
return nullptr; // signals "stop inlining"
|
||||
}
|
||||
|
||||
did_inline.insert(func_vf);
|
||||
|
||||
num_stmts += oi->num_stmts;
|
||||
num_exprs += oi->num_exprs;
|
||||
|
||||
|
@ -265,9 +267,9 @@ ExprPtr Inliner::CheckForInlining(CallExprPtr c)
|
|||
else
|
||||
max_inlined_frame_size = hold_max_inlined_frame_size;
|
||||
|
||||
ListExprPtr args = {NewRef{}, c->Args()};
|
||||
auto t = c->GetType();
|
||||
auto ie = make_intrusive<InlineExpr>(args, std::move(params), body_dup, curr_frame_size, t);
|
||||
auto ie = make_intrusive<InlineExpr>(c->ArgsPtr(), std::move(params), body_dup, curr_frame_size,
|
||||
t);
|
||||
ie->SetOriginal(c);
|
||||
|
||||
return ie;
|
||||
|
|
|
@ -31,10 +31,10 @@ public:
|
|||
// or an InlineExpr if it is; or nil if further inlining should stop.
|
||||
ExprPtr CheckForInlining(CallExprPtr c);
|
||||
|
||||
// True if the given function has been inlined.
|
||||
bool WasInlined(const Func* f)
|
||||
// True if every instance of the function was inlined.
|
||||
bool WasFullyInlined(const Func* f)
|
||||
{
|
||||
return inline_ables.count(f) > 0 && skipped_inlining.count(f) == 0;
|
||||
return did_inline.count(f) > 0 && skipped_inlining.count(f) == 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -52,6 +52,9 @@ protected:
|
|||
// Functions that we've determined to be suitable for inlining.
|
||||
std::unordered_set<const Func*> inline_ables;
|
||||
|
||||
// Functions that we inlined.
|
||||
std::unordered_set<const Func*> did_inline;
|
||||
|
||||
// Functions that we didn't fully inline, so require separate
|
||||
// compilation.
|
||||
std::unordered_set<const Func*> skipped_inlining;
|
||||
|
|
|
@ -517,10 +517,15 @@ static void analyze_scripts_for_ZAM(std::unique_ptr<ProfileFuncs>& pfs)
|
|||
continue;
|
||||
}
|
||||
|
||||
else if ( ! analysis_options.compile_all && ! is_lambda && inl && inl->WasInlined(func) &&
|
||||
func_used_indirectly.count(func) == 0 )
|
||||
else if ( ! analysis_options.compile_all && ! is_lambda && inl &&
|
||||
inl->WasFullyInlined(func) && func_used_indirectly.count(func) == 0 )
|
||||
{
|
||||
// No need to compile as it won't be called directly.
|
||||
// We'd like to zero out the body to recover the
|
||||
// memory, but a *few* such functions do get called,
|
||||
// such as by the event engine reaching up, or
|
||||
// BiFs looking for them, so we can't safely zero
|
||||
// them.
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue