Optimize returns at end of functions.
This commit is contained in:
parent
2076b0219d
commit
d65d8fda54
|
|
@ -94,6 +94,15 @@ void AstNode::init() {
|
|||
m_user5Cnt = 0;
|
||||
}
|
||||
|
||||
AstNode* AstNode::abovep() const {
|
||||
// m_headtailp only valid at beginning or end of list
|
||||
// Avoid supporting at other locations as would require walking
|
||||
// list which is likely to cause performance issues.
|
||||
UASSERT_OBJ(!m_nextp || firstAbovep(), this, "abovep() not allowed when in midlist");
|
||||
const AstNode* firstp = firstAbovep() ? this : m_headtailp;
|
||||
return firstp->backp();
|
||||
}
|
||||
|
||||
string AstNode::encodeName(const string& namein) {
|
||||
// Encode signal name raw from parser, then not called again on same signal
|
||||
string out;
|
||||
|
|
|
|||
|
|
@ -1243,6 +1243,7 @@ public:
|
|||
const char* typeName() const { return type().ascii(); } // See also prettyTypeName
|
||||
AstNode* nextp() const { return m_nextp; }
|
||||
AstNode* backp() const { return m_backp; }
|
||||
AstNode* abovep() const; // Parent node above, only when no nextp() as otherwise slow
|
||||
AstNode* op1p() const { return m_op1p; }
|
||||
AstNode* op2p() const { return m_op2p; }
|
||||
AstNode* op3p() const { return m_op3p; }
|
||||
|
|
|
|||
|
|
@ -2180,7 +2180,20 @@ private:
|
|||
virtual void visit(AstJumpGo* nodep) {
|
||||
iterateChildren(nodep);
|
||||
m_hasJumpGo = true;
|
||||
if (m_doExpensive) { nodep->labelp()->user4(true); }
|
||||
if (m_doExpensive) {
|
||||
// If last statement in a jump label we have JumpLabel(...., JumpGo)
|
||||
// Often caused by "return" in a Verilog function. The Go is pointless, remove.
|
||||
if (!nodep->nextp()) {
|
||||
if (AstJumpLabel* aboveLabelp = VN_CAST(nodep->abovep(), JumpLabel)) {
|
||||
if (aboveLabelp == nodep->labelp()) {
|
||||
UINFO(4, "JUMPGO => last remove "<<nodep<<endl);
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
nodep->labelp()->user4(true);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void visit(AstJumpLabel* nodep) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue