track implicit assignments when profiling, associate counts with assignees

This commit is contained in:
Vern Paxson 2021-08-16 10:34:55 -07:00
parent dbb509448f
commit fb101f7b0e
2 changed files with 22 additions and 6 deletions

View file

@ -261,13 +261,17 @@ TraversalCode ProfileFunc::PreExpr(const Expr* e)
}
break;
case EXPR_INCR:
case EXPR_DECR:
case EXPR_ADD_TO:
case EXPR_REMOVE_FROM:
case EXPR_ASSIGN:
{
if ( e->GetOp1()->Tag() == EXPR_REF )
{
auto lhs = e->GetOp1()->GetOp1();
if ( lhs->Tag() == EXPR_NAME )
assignees.insert(lhs->AsNameExpr()->Id());
TrackAssignment(lhs->AsNameExpr()->Id());
}
// else this isn't a direct assignment.
break;
@ -432,6 +436,14 @@ void ProfileFunc::TrackID(const ID* id)
ordered_ids.push_back(id);
}
void ProfileFunc::TrackAssignment(const ID* id)
{
if ( assignees.count(id) > 0 )
++assignees[id];
else
assignees[id] = 1;
}
ProfileFuncs::ProfileFuncs(std::vector<FuncInfo>& funcs,
is_compilable_pred pred, bool _full_record_hashes)