Internals: Fix removing nodes in V3Life (#5365)

This commit is contained in:
Ryszard Rozak
2024-08-14 09:23:24 +02:00
committed by GitHub
parent 9c5c77c69c
commit 563faeb33f
3 changed files with 50 additions and 5 deletions
+3 -5
View File
@@ -46,17 +46,13 @@ class LifeState final {
public:
VDouble0 m_statAssnDel; // Statistic tracking
VDouble0 m_statAssnCon; // Statistic tracking
std::vector<AstNode*> m_unlinkps;
// CONSTRUCTORS
LifeState() = default;
~LifeState() {
V3Stats::addStatSum("Optimizations, Lifetime assign deletions", m_statAssnDel);
V3Stats::addStatSum("Optimizations, Lifetime constant prop", m_statAssnCon);
for (AstNode* ip : m_unlinkps) VL_DO_DANGLING(ip->unlinkFrBack()->deleteTree(), ip);
}
// METHODS
void pushUnlinkDeletep(AstNode* nodep) { m_unlinkps.push_back(nodep); }
};
//######################################################################
@@ -124,6 +120,7 @@ class LifeBlock final {
LifeBlock* const m_aboveLifep; // Upper life, or nullptr
LifeState* const m_statep; // Current global state
bool m_replacedVref = false; // Replaced a variable reference since last clearing
VNDeleter m_deleter; // Used to delay deletion of nodes
public:
LifeBlock(LifeBlock* aboveLifep, LifeState* statep)
@@ -145,7 +142,8 @@ public:
// above our current iteration point.
if (debug() > 4) oldassp->dumpTree("- REMOVE/SAMEBLK: ");
entp->complexAssign();
VL_DO_DANGLING(m_statep->pushUnlinkDeletep(oldassp), oldassp);
oldassp->unlinkFrBack();
VL_DO_DANGLING(m_deleter.pushDeletep(oldassp), oldassp);
++m_statep->m_statAssnDel;
}
}