From 1cc37ad6cead0ca1c74e7fa68d2d1bf0756f2dc8 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 8 May 2024 08:36:24 -0400 Subject: [PATCH] Internals: Add missing VL_DO_DANGLING. No functional change intended. --- src/V3ActiveTop.cpp | 4 ++-- src/V3Assert.cpp | 2 +- src/V3AssertPre.cpp | 2 +- src/V3Delayed.cpp | 2 +- src/V3Descope.cpp | 3 +-- src/V3Force.cpp | 14 ++++++-------- src/V3Inst.cpp | 2 +- src/V3Life.cpp | 5 +---- src/V3LinkCells.cpp | 2 +- src/V3LinkParse.cpp | 2 +- src/V3Premit.cpp | 2 +- src/V3SchedVirtIface.cpp | 2 +- src/V3Split.cpp | 2 +- src/V3SplitAs.cpp | 3 +-- src/V3Table.cpp | 2 +- src/V3Unroll.cpp | 5 ++--- 16 files changed, 23 insertions(+), 31 deletions(-) diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index de1f11d43..2ebebdb12 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -68,7 +68,7 @@ class ActiveTopVisitor final : public VNVisitor { UINFO(4, " ACTIVE " << nodep << endl); // Remove duplicate clocks and such; sensesp() may change! V3Const::constifyExpensiveEdit(nodep); - AstSenTree* const sensesp = nodep->sensesp(); + AstSenTree* sensesp = nodep->sensesp(); UASSERT_OBJ(sensesp, nodep, "nullptr"); if (sensesp->sensesp() && sensesp->sensesp()->isNever()) { // Never executing. Kill it. @@ -106,7 +106,7 @@ class ActiveTopVisitor final : public VNVisitor { // There may be other references to same sense tree, // we'll be removing all references when we get to them, // but don't dangle our pointer yet! - pushDeletep(sensesp); + VL_DO_DANGLING(pushDeletep(sensesp), sensesp); } nodep->sensesp(wantp); } diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 12d366fc5..dff5f0f2d 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -287,7 +287,7 @@ class AssertVisitor final : public VNVisitor { checkifp->isBoundsCheck(true); // To avoid LATCH warning checkifp->branchPred(VBranchPred::BP_UNLIKELY); nodep->replaceWith(checkifp); - pushDeletep(nodep); + VL_DO_DANGLING(pushDeletep(nodep), nodep); } else { iterateChildren(nodep); } diff --git a/src/V3AssertPre.cpp b/src/V3AssertPre.cpp index 9a34cb2c4..878e77d2c 100644 --- a/src/V3AssertPre.cpp +++ b/src/V3AssertPre.cpp @@ -250,7 +250,7 @@ private: } else { nodep->v3fatal("Invalid direction"); } - pushDeletep(nodep->unlinkFrBack()); + VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); } void visit(AstDelay* nodep) override { // Only cycle delays are relevant in this stage; also only process once diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 801e77911..71be19b3a 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -762,7 +762,7 @@ class DelayedVisitor final : public VNVisitor { callp->dtypeSetVoid(); nodep->replaceWith(callp->makeStmt()); } - nodep->deleteTree(); + VL_DO_DANGLING(nodep->deleteTree(), nodep); } // Pre/Post logic are created here and their content need no further changes, so ignore. diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index 56078471f..2b42fc1be 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -223,8 +223,7 @@ class DescopeVisitor final : public VNVisitor { } void visit(AstVarScope* nodep) override { // Delete the varscope when we're finished - nodep->unlinkFrBack(); - pushDeletep(nodep); + VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); } void visit(AstNodeVarRef* nodep) override { iterateChildren(nodep); diff --git a/src/V3Force.cpp b/src/V3Force.cpp index 11e4d51b5..7c19d8fd0 100644 --- a/src/V3Force.cpp +++ b/src/V3Force.cpp @@ -173,13 +173,12 @@ class ForceConvertVisitor final : public VNVisitor { void visit(AstAssignForce* nodep) override { // The AstAssignForce node will be removed for sure - VNRelinker relinker; - nodep->unlinkFrBack(&relinker); - pushDeletep(nodep); - FileLine* const flp = nodep->fileline(); AstNodeExpr* const lhsp = nodep->lhsp(); // The LValue we are forcing AstNodeExpr* const rhsp = nodep->rhsp(); // The value we are forcing it to + VNRelinker relinker; + nodep->unlinkFrBack(&relinker); + VL_DO_DANGLING(pushDeletep(nodep), nodep); // Set corresponding enable signals to ones V3Number ones{lhsp, isRangedDType(lhsp) ? lhsp->width() : 1}; @@ -208,13 +207,12 @@ class ForceConvertVisitor final : public VNVisitor { } void visit(AstRelease* nodep) override { + FileLine* const flp = nodep->fileline(); + AstNodeExpr* const lhsp = nodep->lhsp(); // The LValue we are releasing // The AstRelease node will be removed for sure VNRelinker relinker; nodep->unlinkFrBack(&relinker); - pushDeletep(nodep); - - FileLine* const flp = nodep->fileline(); - AstNodeExpr* const lhsp = nodep->lhsp(); // The LValue we are releasing + VL_DO_DANGLING(pushDeletep(nodep), nodep); // Set corresponding enable signals to zero V3Number zero{lhsp, isRangedDType(lhsp) ? lhsp->width() : 1}; diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 7776a5de5..d8c810180 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -463,7 +463,7 @@ private: pushDeletep(pinVarp); } // else pinVarp already unlinked when another instance did this step nodep->replaceWith(prevPinp); - pushDeletep(nodep); + VL_DO_DANGLING(pushDeletep(nodep), nodep); } } diff --git a/src/V3Life.cpp b/src/V3Life.cpp index d5292bdb8..030624b10 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -53,10 +53,7 @@ public: ~LifeState() { V3Stats::addStatSum("Optimizations, Lifetime assign deletions", m_statAssnDel); V3Stats::addStatSum("Optimizations, Lifetime constant prop", m_statAssnCon); - for (AstNode* ip : m_unlinkps) { - ip->unlinkFrBack(); - ip->deleteTree(); - } + for (AstNode* ip : m_unlinkps) VL_DO_DANGLING(ip->unlinkFrBack()->deleteTree(), ip); } // METHODS void pushUnlinkDeletep(AstNode* nodep) { m_unlinkps.push_back(nodep); } diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index 8bf4e41ee..e204336b7 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -273,7 +273,7 @@ class LinkCellsVisitor final : public VNVisitor { iterateAndNextNull(cellsp); } } - pushDeletep(nodep->unlinkFrBack()); + VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); } void visit(AstCell* nodep) override { diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 3d9e23ec1..9820aead9 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -874,7 +874,7 @@ class LinkParseVisitor final : public VNVisitor { itemp->v3fatalSrc("Incorrect direction"); } } - pushDeletep(itemp->unlinkFrBack()); + VL_DO_DANGLING(pushDeletep(itemp->unlinkFrBack()), itemp); } iterateChildren(nodep); } diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index 44036735c..a8fafd90d 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -86,7 +86,7 @@ class PremitVisitor final : public VNVisitor { // Extract into constant pool. const bool merge = v3Global.opt.fMergeConstPool(); varp = v3Global.rootp()->constPoolp()->findConst(constp, merge)->varp(); - nodep->deleteTree(); + VL_DO_DANGLING(nodep->deleteTree(), nodep); ++m_extractedToConstPool; } else { // Keep as local temporary. diff --git a/src/V3SchedVirtIface.cpp b/src/V3SchedVirtIface.cpp index 4c8254d42..a49aec90b 100644 --- a/src/V3SchedVirtIface.cpp +++ b/src/V3SchedVirtIface.cpp @@ -132,7 +132,7 @@ private: nodep->replaceWith(postp); postp->addStmtsp( new AstAssign{flp, nodep->lhsp()->unlinkFrBack(), nodep->rhsp()->unlinkFrBack()}); - nodep->deleteTree(); + VL_DO_DANGLING(nodep->deleteTree(), nodep); } } void visit(AstNodeIf* nodep) override { diff --git a/src/V3Split.cpp b/src/V3Split.cpp index f64c4cf9e..2dc7ddb1d 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -819,7 +819,7 @@ class RemovePlaceholdersVisitor final : public VNVisitor { } } if (emptyOrCommentOnly) { - pushDeletep(nodep->unlinkFrBack()); + VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); ++m_emptyAlways; } } diff --git a/src/V3SplitAs.cpp b/src/V3SplitAs.cpp index 029144d52..145e81a39 100644 --- a/src/V3SplitAs.cpp +++ b/src/V3SplitAs.cpp @@ -93,8 +93,7 @@ class SplitAsCleanVisitor final : public VNVisitor { m_keepStmt = true; } else { UINFO(6, " Delete STMT " << nodep << endl); - nodep->unlinkFrBack(); - pushDeletep(nodep); + VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); } } // If something below matches, the upper statement remains too. diff --git a/src/V3Table.cpp b/src/V3Table.cpp index 4bda96e1c..81a2f359b 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -79,7 +79,7 @@ public: : m_fl{fl} {} ~TableBuilder() { - if (m_initp) m_initp->deleteTree(); + if (m_initp) VL_DO_DANGLING(m_initp->deleteTree(), m_initp); } void setTableSize(AstNodeDType* elemDType, unsigned size) { diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index b151e653b..25eb43d89 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -204,8 +204,7 @@ class UnrollVisitor final : public VNVisitor { iterateAndNextNull(tempp->stmtsp()); m_varModeReplace = false; clonep = tempp->stmtsp()->unlinkFrBackWithNext(); - tempp->deleteTree(); - tempp = nullptr; + VL_DO_CLEAR(tempp->deleteTree(), tempp = nullptr); VL_DO_CLEAR(pushDeletep(m_varValuep), m_varValuep = nullptr); } SimulateVisitor simvis; @@ -456,7 +455,7 @@ class UnrollVisitor final : public VNVisitor { && nodep->access().isReadOnly()) { AstNode* const newconstp = m_varValuep->cloneTree(false); nodep->replaceWith(newconstp); - pushDeletep(nodep); + VL_DO_DANGLING(pushDeletep(nodep), nodep); } }