Fix inlining of forks (#3594)

Before this change, some forked processes were being inlined in
`V3Timing` because they contained no `CAwait`s. This only works under
the assumption that no `CAwait`s will be added there later, which is not
true, as a function called by a forked process could be turned into a
coroutine later. The call would be wrapped in a new `CAwait`, but the
process itself would have already been inlined at this point.

This commit moves the inlining to `transformForks` in `V3SchedTiming`,
which is called at a point when all `CAwait`s are already in place.

Signed-off-by: Krzysztof Bieganski <[email protected]>
This commit is contained in:
Krzysztof Bieganski
2022-09-05 15:19:19 +01:00
committed by GitHub
parent 54f89bce42
commit a2e1b32a1c
4 changed files with 54 additions and 45 deletions
+5 -18
View File
@@ -614,25 +614,12 @@ private:
VL_RESTORER(m_procp);
m_procp = beginp;
iterate(beginp);
if (!m_procp->user2()) {
// No awaits, we can inline this process
if (auto* const stmtsp = beginp->stmtsp()) {
nodep->addHereThisAsNext(stmtsp->unlinkFrBackWithNext());
}
VL_DO_DANGLING(beginp->unlinkFrBack()->deleteTree(), beginp);
// We inlined at least one process, so we can consider it joined; convert join_any
// to join_none
if (nodep->joinType().joinAny()) nodep->joinType(VJoinType::JOIN_NONE);
} else {
// Name the begin (later the name will be used for a new function)
beginp->name(nodep->name() + "__" + cvtToStr(idx++));
}
}
if (!nodep->stmtsp()) {
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
} else if (!nodep->joinType().joinNone()) {
makeForkJoin(nodep);
// Even if we do not find any awaits, we cannot simply inline the process here, as new
// awaits could be added later.
// Name the begin (later the name will be used for a new function)
beginp->name(nodep->name() + "__" + cvtToStr(idx++));
}
if (!nodep->joinType().joinNone()) makeForkJoin(nodep);
}
//--------------------