Optimize instance port connections by aliasing rather than by assignment (#8427)

Use AstAlias instead of AstAssignW in V3Inst port connection lowering,
the same way as V3Inline would do if the instance is inlined. This
closes some of the gap between -finline and -fno-inline behaviour, and
is also required for moving V3Inline post scope, where it could not
create aliases anymore (hence required for future patch to maintain
current behaviour).

This is also a partial fix to #4698 (only when the connected expression
is a plain VarRef)
This commit is contained in:
Geza Lore
2026-09-22 20:27:21 +01:00
committed by GitHub
parent 0ab3915de6
commit 6eced23e84
8 changed files with 200 additions and 26 deletions
+3 -4
View File
@@ -599,8 +599,9 @@ class FsmDetectVisitor final : public VNVisitor {
if (!fsmRegisterWrapperDesc(cellp)) return;
UASSERT_OBJ(lhsVscp->varp()->isInput(), nodep,
"Child-side port alias lhs should be an input");
UASSERT_OBJ(rhsVscp->scopep() == m_scopep, nodep,
"Child input port alias should connect from the parent scope");
// Note the connected variable can live in a scope further up, as V3Inst
// aliases a port connection, merging the port variable of an instance into
// whatever it is connected to
m_cellPortAliases[cellp][lhsVscp->varp()->name()] = rhsVscp;
m_cellPortChildAliases[cellp][lhsVscp->varp()->name()] = lhsVscp;
addWrapperCell(m_scopep, cellp);
@@ -608,8 +609,6 @@ class FsmDetectVisitor final : public VNVisitor {
if (!fsmRegisterWrapperDesc(cellp)) return;
UASSERT_OBJ(rhsVscp->varp()->isWritable(), nodep,
"Child-side port alias rhs should be writable");
UASSERT_OBJ(lhsVscp->scopep() == m_scopep, nodep,
"Child output port alias should connect into the parent scope");
m_cellPortAliases[cellp][rhsVscp->varp()->name()] = lhsVscp;
m_cellPortChildAliases[cellp][rhsVscp->varp()->name()] = rhsVscp;
addWrapperCell(m_scopep, cellp);