Optimize away netlist teardown when about to exit (#8294)

This commit is contained in:
Geza Lore
2026-09-06 18:08:34 -04:00
committed by GitHub
parent 849cc5aeca
commit bbbb9c3e7c
7 changed files with 22 additions and 17 deletions
+10 -11
View File
@@ -127,7 +127,6 @@ V3Global v3Global;
static void reportStatsIfEnabled() {
if (v3Global.opt.stats()) {
FileLine::stats();
V3Stats::statsFinalAll(v3Global.rootp());
V3Stats::statsReport();
}
}
@@ -207,10 +206,7 @@ static void process() {
V3Hierarchical::createGraph(v3Global.rootp());
// If a plan is created, further analysis is not necessary.
// The actual Verilation will be done based on this plan.
if (v3Global.hierGraphp()) {
reportStatsIfEnabled();
return;
}
if (v3Global.hierGraphp()) return;
}
// Calculate and check widths, edit tree to TRUNC/EXTRACT any width mismatches
@@ -817,12 +813,6 @@ static bool verilate(const string& argString) {
// Final writing shouldn't throw warnings, but...
V3Error::abortIfWarnings();
// Free memory so compiler has more for --build
// No need to do this if skipped (above) as didn't alloc much
UINFO(1, "Releasing netlist memory");
v3Global.rootp()->deleteContents();
V3Os::releaseMemory();
if (v3Global.opt.stats()) V3Stats::statsStage("released");
return true;
}
@@ -846,10 +836,18 @@ static string buildMakeCmd(const string& makefile, const string& target) {
return cmd.str();
}
static void releaseNetlistMemory() {
UINFO(1, "Releasing netlist memory");
v3Global.rootp()->deleteContents();
V3Os::releaseMemory();
if (v3Global.opt.stats()) V3Stats::statsStage("released");
}
static void execBuildJob() {
UASSERT(v3Global.opt.build(), "--build is not specified.");
UASSERT(v3Global.opt.gmake(), "--build requires GNU Make.");
UASSERT(!v3Global.opt.makeJson(), "--build cannot use json build.");
releaseNetlistMemory();
const VlOs::DeltaWallTime buildWallTime{true};
UINFO(1, "Start Build");
@@ -866,6 +864,7 @@ static void execBuildJob() {
static void execHierVerilation() {
UASSERT(v3Global.hierGraphp(), "must be called only when plan exists");
releaseNetlistMemory();
const string makefile = v3Global.opt.prefix() + "_hier.mk ";
const string target = v3Global.opt.build() ? " hier_build" : " hier_verilation";
const string cmdStr = buildMakeCmd(makefile, target);