Fix cell scoping performance (#6059).

This commit is contained in:
Wilson Snyder 2025-09-06 08:35:07 -04:00
parent 0d1f036f17
commit aa28a8d1e1
3 changed files with 22 additions and 16 deletions

View File

@ -17,6 +17,7 @@ Verilator 5.041 devel
* Improve automatic selection of logic for DFG synthesis (#6370). [Geza Lore] * Improve automatic selection of logic for DFG synthesis (#6370). [Geza Lore]
* Improve `covergroup with function sample` handling (#6387). [Jakub Wasilewski] * Improve `covergroup with function sample` handling (#6387). [Jakub Wasilewski]
* Optimize dead functions without references (#6380). [Artur Bieniek, Antmicro Ltd.] * Optimize dead functions without references (#6380). [Artur Bieniek, Antmicro Ltd.]
* Fix cell scoping performance (#6059). [Jerry Tianchen]
* Fix while loop hang on timing-delayed assignment (#6343) (#6354). [Krzysztof Bieganski, Antmicro Ltd.] * Fix while loop hang on timing-delayed assignment (#6343) (#6354). [Krzysztof Bieganski, Antmicro Ltd.]
* Fix driver analysis of partially assigned variables (#6364) (#6378). [Geza Lore] * Fix driver analysis of partially assigned variables (#6364) (#6378). [Geza Lore]
* Fix V3Hash MacOS ambiguity (#6350). [Lan Zongwei] * Fix V3Hash MacOS ambiguity (#6350). [Lan Zongwei]

View File

@ -428,6 +428,7 @@ Terpstra
Thiede Thiede
Thierry Thierry
Thyer Thyer
Tianchen
Tianrui Tianrui
Tichelaar Tichelaar
Timi Timi

View File

@ -115,9 +115,14 @@ class ScopeVisitor final : public VNVisitor {
nodep, scopename, m_aboveScopep, m_aboveCellp}; nodep, scopename, m_aboveScopep, m_aboveCellp};
if (VN_IS(nodep, Package)) m_packageScopes.emplace(nodep, m_scopep); if (VN_IS(nodep, Package)) m_packageScopes.emplace(nodep, m_scopep);
// Now for each child cell, iterate the module this cell points to // Get list of cells before we edit, to avoid excess visits (issue #6059)
std::deque<AstCell*> cells;
for (AstNode* cellnextp = nodep->stmtsp(); cellnextp; cellnextp = cellnextp->nextp()) { for (AstNode* cellnextp = nodep->stmtsp(); cellnextp; cellnextp = cellnextp->nextp()) {
if (AstCell* const cellp = VN_CAST(cellnextp, Cell)) { if (AstCell* const cellp = VN_CAST(cellnextp, Cell)) cells.push_back(cellp);
}
// Now for each child cell, iterate the module this cell points to
for (AstCell* const cellp : cells) {
VL_RESTORER(m_scopep); // Protects m_scopep set in called module VL_RESTORER(m_scopep); // Protects m_scopep set in called module
// which is "above" in this code, but later in code execution order // which is "above" in this code, but later in code execution order
VL_RESTORER(m_aboveCellp); VL_RESTORER(m_aboveCellp);
@ -134,7 +139,6 @@ class ScopeVisitor final : public VNVisitor {
} }
} }
} }
}
// Create scope for the current usage of this module // Create scope for the current usage of this module
UINFO(4, " back AT " << scopename << " " << nodep); UINFO(4, " back AT " << scopename << " " << nodep);