From 78c9e7773a3a027b3c24294869b4cd46ba975732 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Tue, 5 Aug 2025 11:18:33 +0100 Subject: [PATCH] Allow more variable removal in scoped DFG (#6260) --- src/V3DfgVertices.h | 11 +++++++---- test_regress/t/t_cover_toggle.py | 2 +- test_regress/t/t_inst_tree_inl0_pub1.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/V3DfgVertices.h b/src/V3DfgVertices.h index 6ecc63e6a..13370c807 100644 --- a/src/V3DfgVertices.h +++ b/src/V3DfgVertices.h @@ -87,10 +87,13 @@ public: // Variable referenced outside the containing module/netlist. bool hasExtRefs() const { - if (m_varp->isIO()) return true; // Ports - if (m_varp->isTrace()) return true; // Traced - if (m_varp->isForced()) return true; // Forced - if (hasXRefs()) return true; // Target of a hierarchical reference + // In scoped mode, we can ignrore some of these as they were made explicit by then + if (!m_varScopep) { + if (m_varp->isIO()) return true; // Ports + if (m_varp->isTrace()) return true; // Traced + if (m_varp->isForced()) return true; // Forced + if (hasXRefs()) return true; // Target of a hierarchical reference + } if (m_varp->isPrimaryIO()) return true; // Top level ports if (m_varp->isSigPublic()) return true; // Public return false; diff --git a/test_regress/t/t_cover_toggle.py b/test_regress/t/t_cover_toggle.py index 6f37d0c84..f8d39fb82 100755 --- a/test_regress/t/t_cover_toggle.py +++ b/test_regress/t/t_cover_toggle.py @@ -21,7 +21,7 @@ test.inline_checks() test.file_grep_not(test.obj_dir + "/coverage.dat", "largeish") if test.vlt_all: - test.file_grep(test.stats, r'Coverage, Toggle points joined\s+(\d+)', 13) + test.file_grep(test.stats, r'Coverage, Toggle points joined\s+(\d+)', 14) test.run(cmd=[ os.environ["VERILATOR_ROOT"] + "/bin/verilator_coverage", diff --git a/test_regress/t/t_inst_tree_inl0_pub1.py b/test_regress/t/t_inst_tree_inl0_pub1.py index 4e35f9ef5..5aca960d1 100755 --- a/test_regress/t/t_inst_tree_inl0_pub1.py +++ b/test_regress/t/t_inst_tree_inl0_pub1.py @@ -42,7 +42,7 @@ if test.vlt_all: # We expect to combine sequent functions across multiple instances of # l2, l3, l4, l5. If this number drops, please confirm this has not broken. test.file_grep(test.stats, r'Optimizations, Combined CFuncs\s+(\d+)', - (91 if test.vltmt else 87)) + (107 if test.vltmt else 114)) # Everything should use relative references check_relative_refs("t", True)