From 8c756745917a77489fcaaaef332e9695ce3d2c72 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 29 Feb 2012 23:05:11 -0500 Subject: [PATCH] Internals: V3Dead: Avoid iterating over vars we can't remove. --- src/V3Dead.cpp | 24 ++++++++++++++---------- src/verilog.y | 4 ---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index e35af5f9e..c83ca565d 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -70,16 +70,16 @@ class DeadVisitor : public AstNVisitor { private: // NODE STATE // Entire Netlist: - // AstNodeModule::user() -> int. Count of number of cells referencing this module. - // AstVar::user() -> int. Count of number of references - // AstVarScope::user() -> int. Count of number of references + // AstNodeModule::user1() -> int. Count of number of cells referencing this module. + // AstVar::user1() -> int. Count of number of references + // AstVarScope::user1() -> int. Count of number of references AstUser1InUse m_inuser1; // TYPES typedef multimap AssignMap; // STATE - vector m_varsp; // List of all encountered to avoid another loop through tree + vector m_varEtcsp; // List of all encountered to avoid another loop through tree vector m_vscsp; // List of all encountered to avoid another loop through tree AssignMap m_assignMap; // List of all simple assignments for each variable bool m_elimUserVars; // Allow removal of user's vars @@ -130,11 +130,15 @@ private: } virtual void visit(AstVarScope* nodep, AstNUser*) { nodep->iterateChildren(*this); - m_vscsp.push_back(nodep); + if (mightElim(nodep->varp())) { + m_vscsp.push_back(nodep); + } } virtual void visit(AstVar* nodep, AstNUser*) { nodep->iterateChildren(*this); - m_varsp.push_back(nodep); + if (mightElim(nodep)) { + m_varEtcsp.push_back(nodep); + } } virtual void visit(AstNodeAssign* nodep, AstNUser*) { @@ -180,7 +184,7 @@ private: } } } - bool canElim(AstVar* nodep) { + bool mightElim(AstVar* nodep) { return (!nodep->isSigPublic() // Can't elim publics! && !nodep->isIO() && (nodep->isTemp() || nodep->isParam() || m_elimUserVars)); @@ -189,7 +193,7 @@ private: // Delete any unused varscopes for (vector::iterator it = m_vscsp.begin(); it!=m_vscsp.end(); ++it) { AstVarScope* vscp = *it; - if (vscp->user1() == 0 && canElim(vscp->varp())) { + if (vscp->user1() == 0) { UINFO(4," Dead "< eqrange = m_assignMap.equal_range(vscp); for (AssignMap::iterator it = eqrange.first; it != eqrange.second; ++it) { @@ -200,8 +204,8 @@ private: vscp->unlinkFrBack()->deleteTree(); vscp=NULL; } } - for (vector::iterator it = m_varsp.begin(); it!=m_varsp.end(); ++it) { - if ((*it)->user1() == 0 && canElim((*it))) { + for (vector::iterator it = m_varEtcsp.begin(); it!=m_varEtcsp.end(); ++it) { + if ((*it)->user1() == 0) { UINFO(4," Dead "<<(*it)<unlinkFrBack()->deleteTree(); (*it)=NULL; } diff --git a/src/verilog.y b/src/verilog.y index 739d14be1..6f2ca556a 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -3323,7 +3323,3 @@ string V3ParseGrammar::deQuote(FileLine* fileline, string text) { // --report=lookahead // --report=itemset // --graph -// -// Local Variables: -// compile-command: "cd obj_dbg ; /usr/bin/bison -y -d -v ../verilog.y ; cat y.output" -// End: