fix for AST optimization altering top-level body statement

This commit is contained in:
Vern Paxson 2021-05-30 17:37:44 -07:00
parent 22af54dda2
commit 143d306883
3 changed files with 17 additions and 5 deletions

View file

@ -130,13 +130,19 @@ void optimize_func(ScriptFunc* f, std::shared_ptr<ProfileFunc> pf,
rc->SetDefSetsMgr(reduced_rds.GetDefSetsMgr());
auto ud = std::make_unique<UseDefs>(body, rc);
auto ud = std::make_shared<UseDefs>(body, rc);
ud->Analyze();
if ( analysis_options.dump_uds )
ud->Dump();
ud->RemoveUnused();
new_body = ud->RemoveUnused();
if ( new_body != body )
{
f->ReplaceBody(body, new_body);
body = new_body;
}
int new_frame_size =
scope->Length() + rc->NumTemps() + rc->NumNewLocals();