support for more in-depth AST profiling

This commit is contained in:
Vern Paxson 2024-08-05 09:17:46 +01:00 committed by Arne Welzel
parent d2c6208421
commit 857df9f063
2 changed files with 34 additions and 4 deletions

View file

@ -487,10 +487,29 @@ TraversalCode ProfileFunc::PreExpr(const Expr* e) {
TraversalCode ProfileFunc::PreID(const ID* id) {
TrackID(id);
if ( id->IsGlobal() ) {
globals.insert(id);
all_globals.insert(id);
const auto& t = id->GetType();
TrackType(t);
if ( t->Tag() == TYPE_FUNC )
if ( t->AsFuncType()->Flavor() == FUNC_FLAVOR_EVENT )
events.insert(id->Name());
}
// There's no need for any further analysis of this ID.
return TC_ABORTSTMT;
}
TraversalCode ProfileFunc::PreType(const Type* t) {
TrackType(t);
// There's no need for any further analysis of this type.
return TC_ABORTSTMT;
}
void ProfileFunc::TrackType(const Type* t) {
if ( ! t )
return;
@ -514,6 +533,11 @@ void ProfileFunc::TrackID(const ID* id) {
// Already tracked.
return;
if ( id->IsGlobal() ) {
globals.insert(id);
all_globals.insert(id);
}
ordered_ids.push_back(id);
}