From 1f0e80dbd6b8f11f2a3eca2c43a2a293c1de97d3 Mon Sep 17 00:00:00 2001 From: Krzysztof Bieganski Date: Wed, 30 Sep 2026 16:26:54 +0200 Subject: [PATCH] Optimize sched-initial/static/final: call splitCheck once per sub-function (#8549) Signed-off-by: Krzysztof Bieganski --- src/V3Sched.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/V3Sched.cpp b/src/V3Sched.cpp index 39a6109e6..fb655e692 100644 --- a/src/V3Sched.cpp +++ b/src/V3Sched.cpp @@ -309,7 +309,8 @@ void orderSequentially(AstCFunc* funcp, const LogicByScope& lbs) { } subFuncp->addStmtsp(bodyp); if (procp->needProcess()) subFuncp->setNeedProcess(); - util::splitCheck(subFuncp); + // A coroutine holds a single process, so it is complete here + if (procp->isSuspendable()) util::splitCheck(subFuncp); } } else { logicp->unlinkFrBack(); @@ -319,6 +320,14 @@ void orderSequentially(AstCFunc* funcp, const LogicByScope& lbs) { if (activep->backp()) activep->unlinkFrBack(); VL_DO_DANGLING(activep->deleteTree(), activep); } + // Split sub-functions once complete + for (const auto& pair : lbs) { + AstScope* const scopep = pair.first; + if (AstCFunc* const subFuncp = VN_AS(scopep->user1p(), CFunc)) { + util::splitCheck(subFuncp); + scopep->user1p(nullptr); + } + } } //============================================================================