Fix fork scheduling semantics (#6730)

Signed-off-by: Artur Bieniek <[email protected]>
This commit is contained in:
Artur Bieniek
2025-11-26 15:52:53 +03:00
committed by GitHub
parent f4654a451b
commit 2c5ff3f63f
26 changed files with 401 additions and 63 deletions
+32 -6
View File
@@ -622,6 +622,29 @@ private:
return findp;
}
VSymEnt* findForkParentAlias(VSymEnt* symp, const string& ident) {
static const string suffix = "__VgetForkParent";
VSymEnt* const wrapperp = symp->findIdFlat(ident + suffix);
if (!wrapperp) return nullptr;
if (!VN_IS(wrapperp->nodep(), Begin)) return nullptr;
if (VSymEnt* const forkSymp = wrapperp->findIdFlat(ident)) {
if (VN_IS(forkSymp->nodep(), Fork)) return forkSymp;
}
return nullptr;
}
VSymEnt* unwrapForkParent(VSymEnt* symp, const string& ident) {
static const string suffix = "__VgetForkParent";
if (AstBegin* const beginp = VN_CAST(symp->nodep(), Begin)) {
if (VString::endsWith(beginp->name(), suffix)) {
if (VSymEnt* const forkSymp = symp->findIdFlat(ident)) {
if (VN_IS(forkSymp->nodep(), Fork)) return forkSymp;
}
}
}
return symp;
}
VSymEnt* findWithAltFlat(VSymEnt* symp, const string& name, const string& altname) {
VSymEnt* findp = symp->findIdFlat(name);
if (findp) return findp;
@@ -672,9 +695,10 @@ public:
const AstCellInline* inlinep = lookupSymp
? VN_CAST(lookupSymp->nodep(), CellInline)
: nullptr; // Replicated below
if (VSymEnt* const findSymp = findWithAltFallback(lookupSymp, ident, altIdent)) {
lookupSymp = findSymp;
}
VSymEnt* findSymp = findWithAltFallback(lookupSymp, ident, altIdent);
if (!findSymp) findSymp = findForkParentAlias(lookupSymp, ident);
if (findSymp) lookupSymp = unwrapForkParent(findSymp, ident);
// Check this module - cur modname
else if ((cellp && cellp->modp()->origName() == ident)
|| (inlinep && inlinep->origModName() == ident)) {
@@ -720,9 +744,11 @@ public:
if (!lookupSymp) return nullptr; // Not found
}
} else { // Searching for middle submodule, must be a cell name
if (VSymEnt* const findSymp = findWithAltFlat(lookupSymp, ident, altIdent)) {
lookupSymp = findSymp;
} else {
VSymEnt* findSymp = findWithAltFlat(lookupSymp, ident, altIdent);
if (!findSymp) findSymp = findForkParentAlias(lookupSymp, ident);
if (findSymp)
lookupSymp = unwrapForkParent(findSymp, ident);
else {
return nullptr; // Not found
}
}