mirror of
https://github.com/verilator/verilator.git
synced 2026-09-03 08:24:31 +02:00
Fix non-inlined function return value clearing (#6982).
This commit is contained in:
@@ -174,6 +174,20 @@ class LinkResolveVisitor final : public VNVisitor {
|
||||
}
|
||||
VL_RESTORER(m_ftaskp);
|
||||
m_ftaskp = nodep;
|
||||
|
||||
if (nodep->lifetime().isAutomatic() && nodep->fvarp()) {
|
||||
// Must clear automatic function output variable on function invocation
|
||||
AstVar* const fvarp = VN_AS(nodep->fvarp(), Var);
|
||||
AstNode* const crstp = new AstAssign{
|
||||
fvarp->fileline(), new AstVarRef{fvarp->fileline(), fvarp, VAccess::WRITE},
|
||||
new AstCReset{fvarp->fileline(), fvarp, false}};
|
||||
fvarp->noCReset(true);
|
||||
if (nodep->stmtsp()) {
|
||||
nodep->stmtsp()->addHereThisAsNext(crstp);
|
||||
} else {
|
||||
nodep->addStmtsp(crstp);
|
||||
}
|
||||
}
|
||||
iterateChildren(nodep);
|
||||
if (nodep->dpiExport()) nodep->scopeNamep(new AstScopeName{nodep->fileline(), false});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user