Optimize away __Vconfigure if empty function

This commit is contained in:
Wilson Snyder
2026-09-12 14:36:45 -04:00
parent d523500b9b
commit 3bf0018354
4 changed files with 17 additions and 14 deletions
+3 -1
View File
@@ -209,7 +209,9 @@ class EmitCHeader final : public EmitCConstInit {
if (!VN_IS(modp, Class)) {
decorateFirst(first, section);
puts("void " + protect("__Vconfigure") + "(bool first);\n");
if (v3Global.opt.coverage()) {
puts("void " + protect("__Vconfigure") + "(bool first);\n");
}
} else {
decorateFirst(first, section);
const std::string name = V3OutFormatter::quoteNameControls(
+3 -3
View File
@@ -163,12 +163,12 @@ class EmitCImp final : public EmitCFunc {
"(" + modName + "* vlSelf, bool first);");
}
puts("\nvoid " + modName + "::" + protect("__Vconfigure") + "(bool first) {\n");
puts("(void)first; // Prevent unused variable warning\n");
if (v3Global.opt.coverage()) {
puts("\nvoid " + modName + "::" + protect("__Vconfigure") + "(bool first) {\n");
puts("(void)first; // Prevent unused variable warning\n");
puts(modName + "__" + protect("_configure_coverage") + "(this, first);\n");
puts("}\n");
}
puts("}\n");
}
void emitCoverageImp() {
// Rather than putting out VL_COVER_INSERT calls directly, we do it via this
+11 -9
View File
@@ -1277,15 +1277,17 @@ std::vector<std::string> EmitCSyms::getSymCtorStmts() {
add(stmt);
}
add("// Setup each module's pointer back to symbol table (for public functions)");
for (const ScopeModPair& i : m_scopes) {
const AstScope* const scopep = i.first;
AstNodeModule* const modp = i.second;
// first is used by AstCoverDecl's call to __vlCoverInsert
const bool first = !modp->user1();
modp->user1(true);
add(VIdProtect::protectIf(scopep->nameDotless(), scopep->protect()) + "."
+ protect("__Vconfigure") + "(" + (first ? "true" : "false") + ");");
if (v3Global.opt.coverage()) {
add("// Setup each module's pointer back to symbol table (for public functions)");
for (const ScopeModPair& i : m_scopes) {
const AstScope* const scopep = i.first;
AstNodeModule* const modp = i.second;
// first is used by AstCoverDecl's call to __vlCoverInsert
const bool first = !modp->user1();
modp->user1(true);
add(VIdProtect::protectIf(scopep->nameDotless(), scopep->protect()) + "."
+ protect("__Vconfigure") + "(" + (first ? "true" : "false") + ");");
}
}
// Every scope has the same construction shape, so all fold into one table with no
-1
View File
@@ -12,7 +12,6 @@
<map from="PStVCQ" to="__PVT__secret_r"/>
<map from="PSfqS0" to="__PVT__t__DOT__secret_inst"/>
<map from="PSScAO" to="__VactTriggered"/>
<map from="PSx9Nt" to="__Vconfigure"/>
<map from="PSrjMj" to="__Vdly__secret_cyc"/>
<map from="PS4o5S" to="__Vdpiexp_dpix_a_func_TOP__t__DOT__secret_inst"/>
<map from="PStVA8" to="__Vdpiexp_dpix_a_task_TOP__t__DOT__secret_inst"/>