"-O compile-all" option to specify compilation of inlined functions

This commit is contained in:
Vern Paxson 2021-06-01 09:24:17 -07:00
parent 7855557e92
commit b5b58b0a3a
3 changed files with 13 additions and 3 deletions

View file

@ -160,6 +160,7 @@ static void set_analysis_option(const char* opt, Options& opts)
fprintf(stderr, "--optimize options:\n");
fprintf(stderr, " all equivalent to \"inline\" and \"activate\"\n");
fprintf(stderr, " add-C++ generate private C++ for any missing script bodies\n");
fprintf(stderr, " compile-all *if* compiling, compile all scripts, even inlined ones\n");
fprintf(stderr, " dump-uds dump use-defs to stdout; implies xform\n");
fprintf(stderr, " dump-xform dump transformed scripts to stdout; implies xform\n");
fprintf(stderr, " gen-C++ generate C++ script bodies\n");
@ -179,6 +180,8 @@ static void set_analysis_option(const char* opt, Options& opts)
if ( util::streq(opt, "add-C++") )
a_o.add_CPP = true;
else if ( util::streq(opt, "compile-all") )
a_o.activate = a_o.compile_all = true;
else if ( util::streq(opt, "dump-uds") )
a_o.activate = a_o.dump_uds = true;
else if ( util::streq(opt, "dump-xform") )
@ -189,6 +192,8 @@ static void set_analysis_option(const char* opt, Options& opts)
a_o.gen_standalone_CPP = true;
else if ( util::streq(opt, "inline") )
a_o.inliner = true;
else if ( util::streq(opt, "optimize-AST") )
a_o.activate = a_o.optimize_AST = true;
else if ( util::streq(opt, "recursive") )
a_o.inliner = a_o.report_recursive = true;
else if ( util::streq(opt, "report-C++") )
@ -199,8 +204,6 @@ static void set_analysis_option(const char* opt, Options& opts)
a_o.use_CPP = 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
{

View file

@ -223,6 +223,7 @@ void analyze_scripts()
check_env_opt("ZEEK_GEN_CPP", analysis_options.gen_CPP);
check_env_opt("ZEEK_GEN_STANDALONE_CPP",
analysis_options.gen_standalone_CPP);
check_env_opt("ZEEK_COMPILE_ALL", analysis_options.compile_all);
check_env_opt("ZEEK_REPORT_CPP", analysis_options.report_CPP);
check_env_opt("ZEEK_USE_CPP", analysis_options.use_CPP);
@ -523,7 +524,8 @@ void analyze_scripts()
{
auto func = f.Func();
if ( inl && inl->WasInlined(func) &&
if ( ! analysis_options.compile_all &&
inl && inl->WasInlined(func) &&
func_used_indirectly.count(func) == 0 )
// No need to compile as it won't be
// called directly.

View file

@ -61,6 +61,11 @@ struct AnalyOpt {
// If true, use C++ bodies if available.
bool use_CPP = false;
// If true, compile all compileable functions, even those that
// are inlined. Mainly useful for ensuring compatibility for
// some tests in the test suite.
bool compile_all = false;
// If true, report on available C++ bodies.
bool report_CPP = false;