mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 12:08:20 +00:00
ZAM fixes for loops indexed with variables not used in the loop body
This commit is contained in:
parent
e0736afe4c
commit
d1dffd3e1b
1 changed files with 5 additions and 14 deletions
|
@ -681,13 +681,10 @@ const ZAMStmt ZAMCompiler::LoopOverTable(const ForStmt* f, const NameExpr* val)
|
||||||
auto value_var = f->ValueVar();
|
auto value_var = f->ValueVar();
|
||||||
auto body = f->LoopBody();
|
auto body = f->LoopBody();
|
||||||
|
|
||||||
// Check whether the loop variables are actually used in the body.
|
// We used to have more involved logic here to check whether the loop
|
||||||
// This is motivated by an idiom where there's both loop_vars and
|
// variables are actually used in the body. Now that we have '_'
|
||||||
// a value_var, but the script only actually needs the value_var;
|
// loop placeholder variables, this is no longer worth trying to
|
||||||
// and also some weird cases where the script is managing a
|
// optimize for, though we still optimize for those placeholders.
|
||||||
// separate iteration process manually.
|
|
||||||
ProfileFunc body_pf(body);
|
|
||||||
|
|
||||||
int num_unused = 0;
|
int num_unused = 0;
|
||||||
|
|
||||||
auto aux = new ZInstAux(0);
|
auto aux = new ZInstAux(0);
|
||||||
|
@ -695,7 +692,7 @@ const ZAMStmt ZAMCompiler::LoopOverTable(const ForStmt* f, const NameExpr* val)
|
||||||
for ( auto i = 0; i < loop_vars->length(); ++i ) {
|
for ( auto i = 0; i < loop_vars->length(); ++i ) {
|
||||||
auto id = (*loop_vars)[i];
|
auto id = (*loop_vars)[i];
|
||||||
|
|
||||||
if ( body_pf.Locals().count(id) == 0 || id->IsBlank() )
|
if ( id->IsBlank() )
|
||||||
++num_unused;
|
++num_unused;
|
||||||
|
|
||||||
int slot = id->IsBlank() ? -1 : FrameSlot(id);
|
int slot = id->IsBlank() ? -1 : FrameSlot(id);
|
||||||
|
@ -707,12 +704,6 @@ const ZAMStmt ZAMCompiler::LoopOverTable(const ForStmt* f, const NameExpr* val)
|
||||||
|
|
||||||
bool no_loop_vars = (num_unused == loop_vars->length());
|
bool no_loop_vars = (num_unused == loop_vars->length());
|
||||||
|
|
||||||
if ( value_var && body_pf.Locals().count(value_var.get()) == 0 )
|
|
||||||
// This is more clearly a coding botch - someone left in
|
|
||||||
// an unnecessary value_var variable. But might as
|
|
||||||
// well not do the work.
|
|
||||||
value_var = nullptr;
|
|
||||||
|
|
||||||
if ( value_var )
|
if ( value_var )
|
||||||
aux->value_var_type = value_var->GetType();
|
aux->value_var_type = value_var->GetType();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue