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
+14 -1
View File
@@ -2759,7 +2759,20 @@ private:
UINFOTREE(9, nodep, "", "alias");
AstVarScope* aliasVscp = nullptr;
for (AstNode* itemp = nodep->itemsp(); itemp; itemp = itemp->nextp()) {
AstVarScope* const vscp = VN_AS(itemp, VarRef)->varScopep();
AstVarScope* vscp = nullptr;
if (const AstVarRef* const refp = VN_CAST(itemp, VarRef)) {
vscp = refp->varScopep();
} else {
// Reaches into the scope of an instance, look it up by name
const AstVarXRef* const xrefp = VN_AS(itemp, VarXRef);
const string scopename = xrefp->dotted() + "." + xrefp->name();
string baddot;
VSymEnt* okSymp;
VSymEnt* const symp = m_statep->findDotted(xrefp->fileline(), m_modSymp, scopename,
baddot, okSymp, false);
UASSERT_OBJ(symp, nodep, "No symbol for alias item: " << scopename);
vscp = VN_CAST(symp->nodep(), VarScope);
}
UASSERT_OBJ(vscp, nodep, "VarScope unset");
if (aliasVscp) {
setAliasVarScope(aliasVscp, vscp);