Fix variables declared in fork after taskify (#6126)

This commit is contained in:
Kamil Rakoczy 2025-06-26 16:28:58 +02:00 committed by GitHub
parent 818e6d3ebf
commit d183b4edde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -605,6 +605,10 @@ class ForkVisitor final : public VNVisitor {
m_modp->addStmtsp(taskp);
UINFO(9, "new " << taskp);
// We created a task from fork, so make sure that all
// local (to this new task) variables are marked as funcLocal
for (AstVar* const localp : m_forkLocalsp) localp->funcLocal(true);
AstTaskRef* const taskrefp = new AstTaskRef{nodep->fileline(), taskp, m_capturedVarRefsp};
AstStmtExpr* const taskcallp = taskrefp->makeStmt();
// Replaced nodes will be revisited, so we don't need to "lift" the arguments

View File

@ -47,6 +47,14 @@ module t();
$display("Static variable: %d", static_var);
if (static_var != 1)
$stop;
fork
begin
automatic int my_auto_var = 0;
my_auto_var++;
$display("Automatic variable in fork: %d", my_auto_var);
if (my_auto_var != 1) $stop;
end
join_none
$write("*-* All Finished *-*\n");
$finish;
end