Fix access type of function arguments (#4692) (#4694)

This commit is contained in:
Ryszard Rozak
2023-11-14 17:02:13 -05:00
committed by GitHub
parent 9fd5634778
commit 2dba76a7c2
4 changed files with 57 additions and 11 deletions
+3 -11
View File
@@ -30,7 +30,6 @@
#include "V3Const.h"
#include "V3EmitCBase.h"
#include "V3Graph.h"
#include "V3LinkLValue.h"
#include <tuple>
@@ -503,7 +502,6 @@ class TaskVisitor final : public VNVisitor {
}
} else if (portp->isInoutish()) {
// if (debug() >= 9) pinp->dumpTree("-pinrsize- ");
V3LinkLValue::linkLValueSet(pinp);
AstVarScope* const newvscp
= createVarScope(portp, namePrefix + "__" + portp->shortName());
@@ -524,12 +522,6 @@ class TaskVisitor final : public VNVisitor {
beginp->addNext(postassp);
// if (debug() >= 9) beginp->dumpTreeAndNext(cout, "-pinrsize-out- ");
} else if (portp->isWritable()) {
// Make output variables
// Correct lvalue; we didn't know when we linked
// This is slightly scary; are we sure no decisions were made
// before here based on this not being a lvalue?
// Doesn't seem so; V3Unknown uses it earlier, but works ok.
V3LinkLValue::linkLValueSet(pinp);
// Even if it's referencing a varref, we still make a temporary
// Else task(x,x,x) might produce incorrect results
AstVarScope* const newvscp
@@ -1859,9 +1851,9 @@ AstNodeFTask* V3Task::taskConnectWrapNew(AstNodeFTask* taskp, const string& newn
newTaskp->addStmtsp(newAssignp);
}
oldNewVars.emplace(portp, newPortp);
AstArg* const newArgp
= new AstArg{portp->fileline(), portp->name(),
new AstVarRef{portp->fileline(), newPortp, VAccess::READ}};
const VAccess pinAccess = portp->isWritable() ? VAccess::WRITE : VAccess::READ;
AstArg* const newArgp = new AstArg{portp->fileline(), portp->name(),
new AstVarRef{portp->fileline(), newPortp, pinAccess}};
newCallp->addPinsp(newArgp);
}
// Create wrapper call to original, passing arguments, adding setting of return value