Optimize constify within Expand and Subst (#6111)

These passes blow up the Ast size on some designs, so delaying running V3Const
until after the whole pass can notably increase peak memory usage. In this
patch we apply V3Const per CFunc within these passes, which saves on memory.
Added -fno-const-eager to disable the intra-pass V3Const application, for
debugging.
This commit is contained in:
Geza Lore
2025-06-23 17:58:26 -04:00
committed by GitHub
parent d35e4a2b60
commit 2daa09a255
6 changed files with 41 additions and 0 deletions
+10
View File
@@ -357,6 +357,16 @@ class ExpandVisitor final : public VNVisitor {
}
// VISITORS
void visit(AstCFunc* nodep) override {
iterateChildren(nodep);
// Constant fold here, as Ast size can likely be reduced
if (v3Global.opt.fConstEager()) {
AstNode* const editedp = V3Const::constifyEditCpp(nodep);
UASSERT_OBJ(editedp == nodep, editedp, "Should not have replaced CFunc");
}
}
void visit(AstExtend* nodep) override {
if (nodep->user1SetOnce()) return; // Process once
iterateChildren(nodep);