mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 23:28:20 +00:00
ZAM fixes for "for" loops that are only used to choose an element from a table/set
This commit is contained in:
parent
d1dffd3e1b
commit
6660738b7d
3 changed files with 30 additions and 9 deletions
|
@ -158,15 +158,15 @@ bool ZAMCompiler::RemoveDeadCode() {
|
|||
}
|
||||
|
||||
if ( t && t->inst_num > i0->inst_num && (! i1 || t->inst_num <= i1->inst_num) ) {
|
||||
// This is effectively a branch to the next
|
||||
// instruction. Even if i0 is conditional, there's
|
||||
// no point executing it because regardless of the
|
||||
// outcome of the conditional, we go to the next
|
||||
// successive live instruction (and we don't have
|
||||
// conditionals with side effects).
|
||||
KillInst(i0);
|
||||
did_removal = true;
|
||||
continue;
|
||||
// This is effectively a branch to the next instruction.
|
||||
// We can remove it *unless* the instruction has side effects.
|
||||
// Conditionals don't, but loop-iteration-advancement
|
||||
// instructions do.
|
||||
if ( ! i0->IsLoopIterationAdvancement() ) {
|
||||
KillInst(i0);
|
||||
did_removal = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ( i0->DoesNotContinue() && i1 && i1->num_labels == 0 ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue