Fix nested named fork disable propagation (Part 4 of #7857) (#8001)

This commit is contained in:
Marco Bartoli
2026-07-29 14:49:34 +01:00
committed by GitHub
parent cac2c3df13
commit c3be3c8050
4 changed files with 282 additions and 39 deletions
+13 -2
View File
@@ -749,10 +749,21 @@ class TimingControlVisitor final : public VNVisitor {
addDebugInfo(donep);
beginp->addStmtsp(donep->makeStmt());
}
static bool hasDisableQueuePushSelfPrefix(const AstBegin* const beginp) {
static bool hasDisableQueuePushSelfPrefix(AstBegin* const beginp) {
// LinkJump prepends disable-by-name registration as:
// __VprocessQueue_*.push_back(std::process::self())
return beginp->stmtsp() && beginp->stmtsp()->isDisableQueuePushSelfStmt();
// V3LiftExpr lifts std::process::self() into an assignment to a temporary, then V3Task
// lowers that assignment's function call into a leading comment and AstStmtExpr. Thus the
// push_back is no longer necessarily the first statement. Scan across this generated
// prefix for it, stopping at the fork-start sentinel or the branch body. Registrations for
// nested forks live in sub-blocks and so are not in this statement list.
for (AstNode* stmtp = beginp->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
if (VN_IS(stmtp, Comment)) continue;
AstStmtExpr* const stmtExprp = VN_CAST(stmtp, StmtExpr);
if (!stmtExprp) break;
if (stmtExprp->isDisableQueuePushSelfStmt()) return true;
}
return false;
}
// Register a callback so killing a process-backed fork branch decrements the join counter
void addForkOnKill(AstBegin* const beginp, AstVarScope* const forkVscp) const {