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

@ -5,6 +5,7 @@
#pragma once
#include <optional>
#include <regex>
#include <string>
#include "zeek/Expr.h"
@ -24,9 +25,14 @@ namespace zeek::detail
struct AnalyOpt
{
// If non-nil, then only analyze the given function/event/hook.
// If non-nil, then only analyze function/event/hook(s) whose names
// match one of the given regular expressions.
//
// Applies to both ZAM and C++.
std::optional<std::string> only_func;
std::vector<std::regex> only_funcs;
// Same, but for the filenames where the function is found.
std::vector<std::regex> only_files;
// For a given compilation target, report functions that can't
// be compiled.
@ -68,7 +74,7 @@ struct AnalyOpt
// If true, dump out transformed code: the results of reducing
// interpreted scripts, and, if optimize is set, of then optimizing
// them. Always done if only_func is set.
// them.
bool dump_xform = false;
// If true, dump out the use-defs for each analyzed function.
@ -166,6 +172,16 @@ extern void analyze_func(ScriptFuncPtr f);
// be Invoked, or its body executed directly, to execute the statements.
extern const FuncInfo* analyze_global_stmts(Stmt* stmts);
// Add a pattern to the "only_funcs" list.
extern void add_func_analysis_pattern(AnalyOpt& opts, const char* pat);
// Add a pattern to the "only_files" list.
extern void add_file_analysis_pattern(AnalyOpt& opts, const char* pat);
// True if the given script function & body should be analyzed; otherwise
// it should be skipped.
extern bool should_analyze(const ScriptFuncPtr& f, const StmtPtr& body);
// Analyze all of the parsed scripts collectively for optimization.
extern void analyze_scripts();