Skip to content

Commit

Permalink
Remove deleted nodes from the map, clear the map at the beginning
Browse files Browse the repository at this point in the history
Signed-off-by: Ryszard Rozak <[email protected]>
  • Loading branch information
RRozak committed Oct 10, 2023
1 parent 5a1e04a commit 6f61285
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/V3Const.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 6f61285

Please sign in to comment.