mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 07:08:19 +00:00
fix for ZAM optimization of "while" loops
This commit is contained in:
parent
1563814c4a
commit
6f0441d6f9
1 changed files with 6 additions and 4 deletions
|
@ -469,6 +469,11 @@ bool WhileStmt::IsReduced(Reducer* c) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
StmtPtr WhileStmt::DoReduce(Reducer* c) {
|
StmtPtr WhileStmt::DoReduce(Reducer* c) {
|
||||||
|
if ( loop_cond_pred_stmt )
|
||||||
|
// Important to do this before updating the loop_condition, since
|
||||||
|
// changes to the predecessor statement can alter the condition.
|
||||||
|
loop_cond_pred_stmt = loop_cond_pred_stmt->Reduce(c);
|
||||||
|
|
||||||
if ( c->Optimizing() )
|
if ( c->Optimizing() )
|
||||||
loop_condition = c->OptExpr(loop_condition);
|
loop_condition = c->OptExpr(loop_condition);
|
||||||
else {
|
else {
|
||||||
|
@ -491,9 +496,6 @@ StmtPtr WhileStmt::DoReduce(Reducer* c) {
|
||||||
// we're not actually creating an ExprStmt for execution.
|
// we're not actually creating an ExprStmt for execution.
|
||||||
stmt_loop_condition = with_location_of(make_intrusive<ExprStmt>(STMT_EXPR, loop_condition), this);
|
stmt_loop_condition = with_location_of(make_intrusive<ExprStmt>(STMT_EXPR, loop_condition), this);
|
||||||
|
|
||||||
if ( loop_cond_pred_stmt )
|
|
||||||
loop_cond_pred_stmt = loop_cond_pred_stmt->Reduce(c);
|
|
||||||
|
|
||||||
return ThisPtr();
|
return ThisPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,7 +682,7 @@ StmtPtr StmtList::DoReduce(Reducer* c) {
|
||||||
bool StmtList::ReduceStmt(unsigned int& s_i, std::vector<StmtPtr>& f_stmts, Reducer* c) {
|
bool StmtList::ReduceStmt(unsigned int& s_i, std::vector<StmtPtr>& f_stmts, Reducer* c) {
|
||||||
bool did_change = false;
|
bool did_change = false;
|
||||||
auto& stmt_i = stmts[s_i];
|
auto& stmt_i = stmts[s_i];
|
||||||
auto old_stmt = stmt_i.get();
|
auto old_stmt = stmt_i;
|
||||||
|
|
||||||
auto stmt = stmt_i->Reduce(c);
|
auto stmt = stmt_i->Reduce(c);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue