From 94e71b738a66f3bf9358b39c9018e2e3ab981268 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Thu, 3 Feb 2022 08:53:10 -0800 Subject: [PATCH] minor enhancements for ZAM inlining --- src/Expr.h | 5 +++-- src/script_opt/Expr.cc | 6 ++++++ src/script_opt/Inline.cc | 17 +---------------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/Expr.h b/src/Expr.h index ddfcdaf124..c7eb4cea21 100644 --- a/src/Expr.h +++ b/src/Expr.h @@ -626,8 +626,8 @@ protected: // type (vec, list, table, record). bool IsScalarAggregateOp() const; - // Warns about depreciated scalar vector operations like `[1, 2, - // 3] == 1` or `["a", "b", "c"] + "a"`. + // Warns about deprecated scalar vector operations like + // `[1, 2, 3] == 1` or `["a", "b", "c"] + "a"`. void CheckScalarAggOp() const; ExprPtr op1; @@ -1161,6 +1161,7 @@ public: // Optimization-related: ExprPtr Duplicate() override; + ExprPtr Inline(Inliner* inl) override; bool HasReducedOps(Reducer* c) const override; ExprPtr Reduce(Reducer* c, StmtPtr& red_stmt) override; diff --git a/src/script_opt/Expr.cc b/src/script_opt/Expr.cc index b4db48a6ec..95f2274150 100644 --- a/src/script_opt/Expr.cc +++ b/src/script_opt/Expr.cc @@ -1858,6 +1858,12 @@ ExprPtr RecordConstructorExpr::Duplicate() return SetSucc(new RecordConstructorExpr(op_l)); } +ExprPtr RecordConstructorExpr::Inline(Inliner* inl) + { + op = op->Inline(inl)->AsListExprPtr(); + return ThisPtr(); + } + bool RecordConstructorExpr::HasReducedOps(Reducer* c) const { auto& exprs = op->AsListExpr()->Exprs(); diff --git a/src/script_opt/Inline.cc b/src/script_opt/Inline.cc index 15e1c81391..f9b3e12fd5 100644 --- a/src/script_opt/Inline.cc +++ b/src/script_opt/Inline.cc @@ -125,23 +125,8 @@ void Inliner::Analyze() } 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, - // even though almost none will be called directly) for a - // modest gain of having compiled code for those rare - // circumstances in which a Zeek function can be called - // not ultimately stemming from an event (such as global - // scripting, or expiration functions). - - if ( should_analyze(func_ptr, body) && inline_ables.count(func) == 0 ) + if ( should_analyze(f.FuncPtr(), f.Body()) ) InlineFunction(&f); - } } void Inliner::InlineFunction(FuncInfo* f)