Fix library method argument references (#8252)

Each VCMethod now carries a signature describing the access required of
the references passed as arguments to the call. 'r' if the argument is
read, 'w' if it is fully assigned so the old value does not matter, 'm'
if it is modified (or only conditionally assigned), with a trailing '+'
repeating the preceding entry for all remaining arguments.  Signatures
are validated at compile time, and V3Broken checks the arguments of
every AstCMethodHard against them.

The incorrect references this found and that are easy to fix are
repaired in this patch. "TODO" marks method that are currently broken or
not yet fit the scheme, these will be fixed in follow up patches.

Also renames SCHED_COMMIT and SCHED_ENQUEUE to NBA_COMMIT and
NBA_ENQUEUE, and remove unused methods.
This commit is contained in:
Geza Lore
2026-09-05 19:48:07 +01:00
committed by GitHub
parent 338c6c2885
commit d04647f459
11 changed files with 304 additions and 187 deletions
+12 -8
View File
@@ -268,7 +268,7 @@ public:
}
static AstVarRef* getOneVarRef(AstNodeExpr* forceStmtp) {
AstNode* const basep = AstArraySel::baseFromp(forceStmtp, true);
AstNode* const basep = forceStmtp->baseFromp(true);
if (AstSampled* sampledp = VN_CAST(basep, Sampled))
if (AstNodeExpr* exprp = VN_CAST(sampledp->exprp(), NodeExpr))
return getOneVarRef(exprp);
@@ -822,8 +822,9 @@ public:
AstNodeExpr* createForceReadExpression(const VarForceInfo& varInfo,
AstVarRef* originalRefp) const {
FileLine* const flp = originalRefp->fileline();
return createForceReadCall(varInfo, flp, VCMethod::FORCE_READ,
originalRefp->cloneTreePure(false), originalRefp->varp(),
AstVarRef* const refp = originalRefp->cloneTreePure(false);
refp->access(VAccess::READ);
return createForceReadCall(varInfo, flp, VCMethod::FORCE_READ, refp, refp->varp(),
nullptr);
}
@@ -831,8 +832,11 @@ public:
AstNodeExpr* originalExprp,
AstNodeExpr* indexExprp) const {
FileLine* const flp = originalExprp->fileline();
return createForceReadCall(varInfo, flp, VCMethod::FORCE_READ_INDEX,
originalExprp->cloneTreePure(false), originalExprp, indexExprp);
AstNodeExpr* const exprp = originalExprp->cloneTreePure(false);
// Must be an LValue to a static variable
VN_AS(exprp->cLValueTargetp(), VarRef)->access(VAccess::READ);
return createForceReadCall(varInfo, flp, VCMethod::FORCE_READ_INDEX, exprp, originalExprp,
indexExprp);
}
static AstNodeExpr* rebuildSelPath(AstNodeExpr* pathp, AstNodeExpr* baseExprp) {
@@ -1315,7 +1319,7 @@ class ForceReplaceVisitor final : public VNVisitor {
m_stmtp = nodep;
iterate(nodep->lhsp());
iterate(nodep->rhsp());
if (AstVarRef* const lhsp = VN_CAST(AstArraySel::baseFromp(nodep->lhsp(), true), VarRef)) {
if (AstVarRef* const lhsp = VN_CAST(nodep->lhsp()->baseFromp(true), VarRef)) {
if (AstNode* const updatep
= m_state.createRhsUpdatesForWrite(nodep->fileline(), lhsp->varp())) {
nodep->addNextHere(updatep);
@@ -1394,7 +1398,7 @@ class ForceReplaceVisitor final : public VNVisitor {
}
}
AstNode* const basep = AstArraySel::baseFromp(nodep, true);
AstNode* const basep = nodep->baseFromp(true);
AstVarRef* const baseRefp = VN_CAST(basep, VarRef);
if (!baseRefp) {
iterateChildren(nodep);
@@ -1492,7 +1496,7 @@ class ForceReplaceVisitor final : public VNVisitor {
// Handle the whole opaque path at its outermost node so we can assign one stable
// synthetic force-path index to the full selection/member chain.
AstNodeExpr* const exprp = VN_AS(nodep, NodeExpr);
AstNode* const basep = AstArraySel::baseFromp(exprp, true);
AstNode* const basep = exprp->baseFromp(true);
AstVarRef* const baseRefp = VN_CAST(basep, VarRef);
if (baseRefp) {
AstVar* const varp = baseRefp->varp();