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

@ -103,7 +103,7 @@ public:
{ return locals; }
const std::unordered_set<const ID*>& Params() const
{ return params; }
const std::unordered_set<const ID*>& Assignees() const
const std::unordered_map<const ID*, int>& Assignees() const
{ return assignees; }
const std::unordered_set<const ID*>& Inits() const
{ return inits; }
@ -166,6 +166,9 @@ protected:
// Take note of the presence of an identifier.
void TrackID(const ID* id);
// Take note of an assignment to an identifier.
void TrackAssignment(const ID* id);
// Globals seen in the function.
//
// Does *not* include globals solely seen as the function being
@ -187,10 +190,11 @@ protected:
// function.
int num_params = -1;
// Identifiers (globals, locals, parameters) that are assigned to.
// Does not include implicit assignments due to initializations,
// which are instead captured in "inits".
std::unordered_set<const ID*> assignees;
// Maps identifiers (globals, locals, parameters) to how often
// they are assigned to (no entry if never). Does not include
// implicit assignments due to initializations, which are instead
// captured in "inits".
std::unordered_map<const ID*, int> assignees;
// Same for locals seen in initializations, so we can find,
// for example, unused aggregates.