mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
enable setting "-O optimize-AST" option
This commit is contained in:
parent
56ab0ddcf1
commit
d38cc04e83
3 changed files with 15 additions and 0 deletions
|
@ -151,6 +151,7 @@ static void set_analysis_option(const char* opt, Options& opts)
|
|||
{
|
||||
opts.analysis_options.inliner = true;
|
||||
opts.analysis_options.activate = true;
|
||||
opts.analysis_options.optimize_AST = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -161,6 +162,7 @@ static void set_analysis_option(const char* opt, Options& opts)
|
|||
fprintf(stderr, " dump-xform dump transformed scripts to stdout; implies xform\n");
|
||||
fprintf(stderr, " help print this list\n");
|
||||
fprintf(stderr, " inline inline function calls\n");
|
||||
fprintf(stderr, " optimize-AST optimize the (transformed) AST; implies xform\n");
|
||||
fprintf(stderr, " recursive report on recursive functions and exit\n");
|
||||
fprintf(stderr, " xform tranform scripts to \"reduced\" form\n");
|
||||
exit(0);
|
||||
|
@ -178,6 +180,8 @@ static void set_analysis_option(const char* opt, Options& opts)
|
|||
a_o.inliner = a_o.report_recursive = true;
|
||||
else if ( util::streq(opt, "xform") )
|
||||
a_o.activate = true;
|
||||
else if ( util::streq(opt, "optimize-AST") )
|
||||
a_o.activate = a_o.optimize_AST = true;
|
||||
|
||||
else
|
||||
{
|
||||
|
|
|
@ -133,6 +133,7 @@ void analyze_scripts()
|
|||
check_env_opt("ZEEK_DUMP_XFORM", analysis_options.dump_xform);
|
||||
check_env_opt("ZEEK_DUMP_UDS", analysis_options.dump_uds);
|
||||
check_env_opt("ZEEK_INLINE", analysis_options.inliner);
|
||||
check_env_opt("ZEEK_OPT", analysis_options.optimize_AST);
|
||||
check_env_opt("ZEEK_XFORM", analysis_options.activate);
|
||||
|
||||
auto usage = getenv("ZEEK_USAGE_ISSUES");
|
||||
|
@ -148,6 +149,7 @@ void analyze_scripts()
|
|||
}
|
||||
|
||||
if ( analysis_options.only_func ||
|
||||
analysis_options.optimize_AST ||
|
||||
analysis_options.usage_issues > 0 )
|
||||
analysis_options.activate = true;
|
||||
|
||||
|
@ -157,6 +159,12 @@ void analyze_scripts()
|
|||
if ( ! analysis_options.activate && ! analysis_options.inliner )
|
||||
return;
|
||||
|
||||
if ( analysis_options.usage_issues > 0 && analysis_options.optimize_AST )
|
||||
{
|
||||
fprintf(stderr, "warning: \"-O optimize-AST\" option is incompatible with -u option, deactivating optimization\n");
|
||||
analysis_options.optimize_AST = false;
|
||||
}
|
||||
|
||||
// Now that everything's parsed and BiF's have been initialized,
|
||||
// profile the functions.
|
||||
std::unordered_map<const ScriptFunc*, std::shared_ptr<ProfileFunc>>
|
||||
|
|
|
@ -22,6 +22,9 @@ struct AnalyOpt {
|
|||
// Whether to analyze scripts.
|
||||
bool activate = false;
|
||||
|
||||
// Whether to optimize the AST.
|
||||
bool optimize_AST = false;
|
||||
|
||||
// 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue