mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
replace --optimize-only with --optimize-funcs and --optimize-files
This commit is contained in:
parent
aa91f72b34
commit
9069e744f9
8 changed files with 176 additions and 125 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include "zeek/script_opt/CPP/Compile.h"
|
||||
|
||||
extern std::unordered_set<std::string> files_with_conditionals;
|
||||
|
||||
namespace zeek::detail
|
||||
{
|
||||
|
||||
|
@ -72,29 +74,48 @@ void CPPCompile::Compile(bool report_uncompilable)
|
|||
|
||||
GenProlog();
|
||||
|
||||
unordered_set<string> filenames_reported_as_skipped;
|
||||
|
||||
// Determine which functions we can call directly, and reuse
|
||||
// previously compiled instances of those if present.
|
||||
for ( const auto& func : funcs )
|
||||
for ( auto& func : funcs )
|
||||
{
|
||||
const auto& f = func.Func();
|
||||
|
||||
auto& ofiles = analysis_options.only_files;
|
||||
string fn = func.Body()->GetLocationInfo()->filename;
|
||||
|
||||
if ( ! func.ShouldSkip() && ! ofiles.empty() && files_with_conditionals.count(fn) > 0 )
|
||||
{
|
||||
if ( filenames_reported_as_skipped.count(fn) == 0 )
|
||||
{
|
||||
reporter->Warning(
|
||||
"skipping compilation of files in %s due to presence of conditional code",
|
||||
fn.c_str());
|
||||
filenames_reported_as_skipped.insert(fn);
|
||||
}
|
||||
|
||||
func.SetSkip(true);
|
||||
}
|
||||
|
||||
if ( func.ShouldSkip() )
|
||||
{
|
||||
not_fully_compilable.insert(func.Func()->Name());
|
||||
not_fully_compilable.insert(f->Name());
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( func.Func()->Flavor() != FUNC_FLAVOR_FUNCTION )
|
||||
// Can't be called directly.
|
||||
continue;
|
||||
|
||||
const char* reason;
|
||||
if ( IsCompilable(func, &reason) )
|
||||
compilable_funcs.insert(BodyName(func));
|
||||
{
|
||||
if ( f->Flavor() == FUNC_FLAVOR_FUNCTION )
|
||||
// Note this as a callable compiled function.
|
||||
compilable_funcs.insert(BodyName(func));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( reason && report_uncompilable )
|
||||
fprintf(stderr, "%s cannot be compiled to C++ due to %s\n", func.Func()->Name(),
|
||||
reason);
|
||||
not_fully_compilable.insert(func.Func()->Name());
|
||||
fprintf(stderr, "%s cannot be compiled to C++ due to %s\n", f->Name(), reason);
|
||||
not_fully_compilable.insert(f->Name());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +126,6 @@ void CPPCompile::Compile(bool report_uncompilable)
|
|||
types.AddKey(tp, pfs.HashType(t));
|
||||
}
|
||||
|
||||
// ### This doesn't work for -O add-C++
|
||||
Emit("TypePtr types__CPP[%s];", Fmt(static_cast<int>(types.DistinctKeys().size())));
|
||||
|
||||
NL();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue