From 6f61285af39f1e317682e0c58cb625e6f570f833 Mon Sep 17 00:00:00 2001 From: Ryszard Rozak Date: Tue, 10 Oct 2023 11:50:56 +0200 Subject: [PATCH] Remove deleted nodes from the map, clear the map at the beginning Signed-off-by: Ryszard Rozak --- src/V3Const.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/V3Const.cpp b/src/V3Const.cpp index b625bd0b85..2890e8d171 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -716,7 +716,10 @@ class ConstBitOpTreeVisitor final : public VNVisitorConst { } // Set width and widthMin precisely resultp->dtypeChgWidth(resultWidth, 1); - for (AstNode* const termp : termps) termp->deleteTree(); + for (AstNode* const termp : termps) { + ConstVisitor::s_containsMemberAccess.erase(termp); + termp->deleteTree(); + } return resultp; } const ResultTerm result = v->getResultTerm(); @@ -792,7 +795,10 @@ class ConstBitOpTreeVisitor final : public VNVisitorConst { // Only substitute the result if beneficial as determined by operation count if (visitor.m_ops <= resultOps) { - for (AstNode* const termp : termps) termp->deleteTree(); + for (AstNode* const termp : termps) { + ConstVisitor::s_containsMemberAccess.erase(termp); + termp->deleteTree(); + } return nullptr; } @@ -1044,6 +1050,7 @@ class ConstVisitor final : public VNVisitor { if (!operandsSame(ap, bp)) return false; // Do it cp->unlinkFrBack(); + ConstVisitor::s_containsMemberAccess.erase(andp); VL_DO_DANGLING(andp->unlinkFrBack()->deleteTree(), andp); VL_DANGLING(notp); // Replace whichever branch is now dangling @@ -3768,6 +3775,7 @@ class ConstVisitor final : public VNVisitor { AstNode* mainAcceptEdit(AstNode* nodep) { VIsCached::clearCacheTree(); // Avoid using any stale isPure + s_containsMemberAccess.clear(); // Operate starting at a random place return iterateSubtreeReturnEdits(nodep); }