Skip to content

Commit

Permalink
Fix compilation error on unreachable disable fork / wait fork (verila…
Browse files Browse the repository at this point in the history
…tor#5339)

Signed-off-by: Arkadiusz Kozdra <[email protected]>
  • Loading branch information
kozdra authored Aug 7, 2024
1 parent e6fe367 commit f78c4e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/V3Timing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,17 +341,12 @@ class TimingSuspendableVisitor final : public VNVisitor {
}
}
void visit(AstNodeCCall* nodep) override {
if (!m_underFork || (m_underFork & F_MIGHT_SUSPEND))
new V3GraphEdge{&m_suspGraph, getSuspendDepVtx(nodep->funcp()),
getSuspendDepVtx(m_procp), m_underFork ? P_FORK : P_CALL};
new V3GraphEdge{&m_suspGraph, getSuspendDepVtx(nodep->funcp()), getSuspendDepVtx(m_procp),
P_CALL};

new V3GraphEdge{&m_procGraph, getNeedsProcDepVtx(nodep->funcp()),
getNeedsProcDepVtx(m_procp), P_CALL};

if (m_underFork && !(m_underFork & F_MIGHT_SUSPEND)) {
addFlags(nodep, T_NEEDS_PROC | T_ALLOCS_PROC);
}

iterateChildren(nodep);
}
void visit(AstBegin* nodep) override {
Expand All @@ -365,9 +360,7 @@ class TimingSuspendableVisitor final : public VNVisitor {
new V3GraphEdge{&m_procGraph, getNeedsProcDepVtx(nodep), getNeedsProcDepVtx(m_procp),
P_CALL};

if (m_underFork && !(m_underFork & F_MIGHT_SUSPEND)) {
addFlags(nodep, T_NEEDS_PROC | T_ALLOCS_PROC);
}
if (m_underFork) addFlags(nodep, T_NEEDS_PROC | T_ALLOCS_PROC);

m_procp = nodep;
m_underFork = 0;
Expand Down Expand Up @@ -1128,11 +1121,22 @@ class TimingControlVisitor final : public VNVisitor {
// var
alwaysp->addNextHere(nodep);
}
void visit(AstDisableFork* nodep) override {
if (hasFlags(m_procp, T_HAS_PROC)) return;
// never reached by any process; remove to avoid compilation error
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
}
void visit(AstWaitFork* nodep) override {
AstCExpr* const exprp = new AstCExpr{nodep->fileline(), "vlProcess->completedFork()", 1};
exprp->pure(false);
AstWait* const waitp = new AstWait{nodep->fileline(), exprp, nullptr};
nodep->replaceWith(waitp);
if (hasFlags(m_procp, T_HAS_PROC)) {
AstCExpr* const exprp
= new AstCExpr{nodep->fileline(), "vlProcess->completedFork()", 1};
exprp->pure(false);
AstWait* const waitp = new AstWait{nodep->fileline(), exprp, nullptr};
nodep->replaceWith(waitp);
} else {
// never reached by any process; remove to avoid compilation error
nodep->unlinkFrBack();
}
VL_DO_DANGLING(nodep->deleteTree(), nodep);
}
void visit(AstWait* nodep) override {
Expand Down
7 changes: 7 additions & 0 deletions test_regress/t/t_disable_fork3.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
// any use, without warranty, 2023 by Antmicro Ltd.
// SPDX-License-Identifier: CC0-1.0

class C;
task proc;
disable fork;
wait fork;
endtask
endclass

module t;
initial begin
fork begin
Expand Down

0 comments on commit f78c4e8

Please sign in to comment.