diff --git a/src/script_opt/ScriptOpt.cc b/src/script_opt/ScriptOpt.cc index 47f9fddf24..4a789134e8 100644 --- a/src/script_opt/ScriptOpt.cc +++ b/src/script_opt/ScriptOpt.cc @@ -271,6 +271,7 @@ static void init_options() { check_env_opt("ZEEK_REPORT_UNCOMPILABLE", analysis_options.report_uncompilable); check_env_opt("ZEEK_ZAM_CODE", analysis_options.gen_ZAM_code); check_env_opt("ZEEK_NO_ZAM_OPT", analysis_options.no_ZAM_opt); + check_env_opt("ZEEK_NO_ZAM_CONTROL_FLOW_OPT", analysis_options.no_ZAM_control_flow_opt); check_env_opt("ZEEK_DUMP_ZAM", analysis_options.dump_ZAM); check_env_opt("ZEEK_PROFILE", analysis_options.profile_ZAM); diff --git a/src/script_opt/ScriptOpt.h b/src/script_opt/ScriptOpt.h index 1f58c99a9a..4854936073 100644 --- a/src/script_opt/ScriptOpt.h +++ b/src/script_opt/ScriptOpt.h @@ -72,6 +72,9 @@ struct AnalyOpt { // Deactivate the low-level ZAM optimizer. bool no_ZAM_opt = false; + // Deactivate ZAM optimization of control flow. + bool no_ZAM_control_flow_opt = false; + // Produce a profile of ZAM execution. bool profile_ZAM = false; diff --git a/src/script_opt/ZAM/AM-Opt.cc b/src/script_opt/ZAM/AM-Opt.cc index c21fd6e77c..f242affccc 100644 --- a/src/script_opt/ZAM/AM-Opt.cc +++ b/src/script_opt/ZAM/AM-Opt.cc @@ -144,6 +144,9 @@ bool ZAMCompiler::RemoveDeadCode() { if ( ! i0->live ) continue; + if ( analysis_options.no_ZAM_control_flow_opt ) + continue; + auto i1 = NextLiveInst(i0); // Look for degenerate branches. @@ -181,6 +184,9 @@ bool ZAMCompiler::RemoveDeadCode() { } bool ZAMCompiler::CollapseGoTos() { + if ( analysis_options.no_ZAM_control_flow_opt ) + return false; + bool did_change = false; for ( auto& i0 : insts1 ) {