From c00cc18d37c79f1e9f94ffbd77470f2372aa303a Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 9 May 2020 15:00:36 -0400 Subject: [PATCH] Optimize dead code after gotos --- src/V3Const.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 924ce8c9a..c935aaf81 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -2180,6 +2180,10 @@ private: return; } if (m_doExpensive) { + // Any non-label statements (at this statement level) can never execute + while (nodep->nextp() && !VN_IS(nodep->nextp(), JumpLabel)) { + nodep->nextp()->unlinkFrBack()->deleteTree(); + } // 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()) {