From 18d435ac128f627a388d6dab1f8b61dfef694969 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Mon, 15 Sep 2025 13:57:35 -0700 Subject: [PATCH] fix for tracking identifiers and aggregates when compiling to standalone-C++ --- src/script_opt/CPP/Consts.cc | 13 ++++--------- src/script_opt/ProfileFunc.cc | 2 ++ src/script_opt/ProfileFunc.h | 1 - 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/script_opt/CPP/Consts.cc b/src/script_opt/CPP/Consts.cc index 919533edd0..0b6257246e 100644 --- a/src/script_opt/CPP/Consts.cc +++ b/src/script_opt/CPP/Consts.cc @@ -43,16 +43,11 @@ shared_ptr CPPCompile::RegisterConstant(const ValPtr& vp, int& con // render the same. t->Describe(&d); - // Likewise, tables that have attributes. - if ( t->Tag() == TYPE_TABLE ) { - const auto& attrs = v->AsTableVal()->GetAttrs(); - if ( attrs ) - attrs->Describe(&d); - else - d.Add(""); - } - c_desc = d.Description(); + + // Aggregates need to be pointer-unique. + if ( IsAggr(t) ) + c_desc += util::fmt("pointer %p", static_cast(v)); } auto c = constants.find(c_desc); diff --git a/src/script_opt/ProfileFunc.cc b/src/script_opt/ProfileFunc.cc index 6c4660a4e9..95bcd405e6 100644 --- a/src/script_opt/ProfileFunc.cc +++ b/src/script_opt/ProfileFunc.cc @@ -196,6 +196,8 @@ TraversalCode ProfileFunc::PreExpr(const Expr* e) { auto n = e->AsNameExpr(); auto id = n->IdPtr(); + TrackID(id); + // Turns out that NameExpr's can be constructed using a // different Type* than that of the identifier itself, // so be sure we track the latter too. diff --git a/src/script_opt/ProfileFunc.h b/src/script_opt/ProfileFunc.h index 7942d72b8e..d4ad16300e 100644 --- a/src/script_opt/ProfileFunc.h +++ b/src/script_opt/ProfileFunc.h @@ -107,7 +107,6 @@ public: const std::vector& Exprs() const { return exprs; } const std::vector& Lambdas() const { return lambdas; } const std::vector& Constants() const { return constants; } - const IDSet& UnorderedIdentifiers() const { return ids; } const std::vector& OrderedIdentifiers() const { return ordered_ids; } const TypeSet& UnorderedTypes() const { return types; } const std::vector& OrderedTypes() const { return ordered_types; }