From 70b82f1aec696c52342f368cd169b74531e533b7 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 27 May 2023 11:46:25 -0400 Subject: [PATCH] Internals: V3Dead cleanups. No functional change. --- src/V3Dead.cpp | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index b0d798ab1..73b7f69a3 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -62,9 +62,10 @@ private: // TYPES using AssignMap = std::multimap; - // STATE - AstNodeModule* m_modp = nullptr; // Current module - AstSelLoopVars* m_selloopvarsp = nullptr; // Current loop vars + // STATE - across all visitors + const bool m_elimUserVars; // Allow removal of user's vars + const bool m_elimDTypes; // Allow removal of DTypes + const bool m_elimCells; // Allow removal of Cells // List of all encountered to avoid another loop through tree std::vector m_varsp; std::vector m_dtypesp; @@ -73,13 +74,13 @@ private: std::vector m_cellsp; std::vector m_classesp; std::vector m_typedefsp; - AssignMap m_assignMap; // List of all simple assignments for each variable - const bool m_elimUserVars; // Allow removal of user's vars - const bool m_elimDTypes; // Allow removal of DTypes - const bool m_elimCells; // Allow removal of Cells bool m_sideEffect = false; // Side effects discovered in assign RHS + // STATE - for current visit position (use VL_RESTORER) + AstNodeModule* m_modp = nullptr; // Current module + AstSelLoopVars* m_selloopvarsp = nullptr; // Current loop vars + // METHODS void checkAll(AstNode* nodep) { @@ -107,18 +108,16 @@ private: void visit(AstNodeModule* nodep) override { if (m_modp) m_modp->user1Inc(); // e.g. Class under Package VL_RESTORER(m_modp); - { - m_modp = nodep; - if (!nodep->dead()) { - iterateChildren(nodep); - checkAll(nodep); - if (AstClass* const classp = VN_CAST(nodep, Class)) { - if (classp->extendsp()) classp->extendsp()->user1Inc(); - if (classp->classOrPackagep()) classp->classOrPackagep()->user1Inc(); - m_classesp.push_back(classp); - // TODO we don't reclaim dead classes yet - graph implementation instead? - classp->user1Inc(); - } + m_modp = nodep; + if (!nodep->dead()) { + iterateChildren(nodep); + checkAll(nodep); + if (AstClass* const classp = VN_CAST(nodep, Class)) { + if (classp->extendsp()) classp->extendsp()->user1Inc(); + if (classp->classOrPackagep()) classp->classOrPackagep()->user1Inc(); + m_classesp.push_back(classp); + // TODO we don't reclaim dead classes yet - graph implementation instead? + classp->user1Inc(); } } }