diff --git a/src/script_opt/ProfileFunc.cc b/src/script_opt/ProfileFunc.cc index da6802ff99..b7ccae6f68 100644 --- a/src/script_opt/ProfileFunc.cc +++ b/src/script_opt/ProfileFunc.cc @@ -60,12 +60,23 @@ p_hash_type script_specific_hash(const StmtPtr& body, p_hash_type generic_hash) ProfileFunc::ProfileFunc(const Func* func, const StmtPtr& body, bool _abs_rec_fields) { + profiled_func = func; + profiled_body = body.get(); abs_rec_fields = _abs_rec_fields; Profile(func->GetType().get(), body); } +ProfileFunc::ProfileFunc(const Stmt* s, bool _abs_rec_fields) + { + profiled_body = s; + abs_rec_fields = _abs_rec_fields; + s->Traverse(this); + } + ProfileFunc::ProfileFunc(const Expr* e, bool _abs_rec_fields) { + profiled_expr = e; + abs_rec_fields = _abs_rec_fields; if ( e->Tag() == EXPR_LAMBDA ) @@ -84,12 +95,6 @@ ProfileFunc::ProfileFunc(const Expr* e, bool _abs_rec_fields) e->Traverse(this); } -ProfileFunc::ProfileFunc(const Stmt* s, bool _abs_rec_fields) - { - abs_rec_fields = _abs_rec_fields; - s->Traverse(this); - } - void ProfileFunc::Profile(const FuncType* ft, const StmtPtr& body) { num_params = ft->Params()->NumFields(); diff --git a/src/script_opt/ProfileFunc.h b/src/script_opt/ProfileFunc.h index dbc275eb66..2ccb47f6d6 100644 --- a/src/script_opt/ProfileFunc.h +++ b/src/script_opt/ProfileFunc.h @@ -100,6 +100,12 @@ public: ProfileFunc(const Stmt* body, bool abs_rec_fields = false); ProfileFunc(const Expr* func, bool abs_rec_fields = false); + // Returns the function, body, or expression profiled. Each can be + // null depending on the constructor used. + const Func* ProfiledFunc() const { return profiled_func; } + const Stmt* ProfiledBody() const { return profiled_body; } + const Expr* ProfiledExpr() const { return profiled_expr; } + // See the comments for the associated member variables for each // of these accessors. const std::unordered_set& Globals() const { return globals; } @@ -157,6 +163,12 @@ protected: // Take note of an assignment to an identifier. void TrackAssignment(const ID* id); + // The function, body, or expression profiled. Can be null + // depending on which constructor was used. + const Func* profiled_func = nullptr; + const Stmt* profiled_body = nullptr; + const Expr* profiled_expr = nullptr; + // Globals seen in the function. // // Does *not* include globals solely seen as the function being