Fix inlining of CFuncs with reloop locals (#7132)

The recent V3InlineCFuncs only checks AstCFunc::varsp for locals, but
V3Reloop used to insert them into AstCFunc::stmtsp resulting in multiple
locals with the same name being inlined into the caller if the stars
align. Fix Reloop. Such things will also go away with #6280.
This commit is contained in:
Geza Lore
2026-02-23 17:35:15 +00:00
committed by GitHub
parent 7c923bb330
commit 8c7f08dfc3
3 changed files with 66 additions and 2 deletions
+2 -2
View File
@@ -68,6 +68,7 @@ class ReloopVisitor final : public VNVisitor {
const string newvarname{"__Vilp" + std::to_string(cfuncp->user1Inc() + 1)};
AstVar* const varp
= new AstVar{fl, VVarType::STMTTEMP, newvarname, VFlagLogicPacked{}, 32};
cfuncp->addVarsp(varp);
return varp;
}
void mergeEnd() {
@@ -105,8 +106,7 @@ class ReloopVisitor final : public VNVisitor {
AstLoop* const loopp = new AstLoop{fl};
loopp->addStmtsp(new AstLoopTest{fl, loopp, condp});
initp->addNext(loopp);
itp->AstNode::addNext(initp);
bodyp->replaceWith(itp);
bodyp->replaceWith(initp);
loopp->addStmtsp(bodyp);
loopp->addStmtsp(incp);