Fix splitting of large _eval and related functions

Fix bug that only used to measure size of first statement in functions
to determine if splitting was necessary. Measure whole function instead.
This commit is contained in:
Geza Lore 2021-12-20 10:56:46 +00:00
parent 4135867e53
commit 1de2de4bde
4 changed files with 18 additions and 13 deletions

View File

@ -27,6 +27,7 @@ Verilator 4.217 devel
* Fix VL_STREAML_FAST_QQI with 64 bit left-hand-side (#3232) (#3235)
* Fix $sformat of inputs/outputs (#3236). [Adrien Le Masle]
* Fix associative array foreach loop (#3229).
* Fix splitting of _eval and other top level functions. [Geza Lore, Shunyao CAD]
Verilator 4.216 2021-12-05

View File

@ -207,8 +207,7 @@ private:
}
void splitCheck(AstCFunc* ofuncp) {
if (!v3Global.opt.outputSplitCFuncs() || !ofuncp->stmtsp()) return;
if (EmitCBaseCounterVisitor(ofuncp->stmtsp()).count() < v3Global.opt.outputSplitCFuncs())
return;
if (EmitCBaseCounterVisitor(ofuncp).count() < v3Global.opt.outputSplitCFuncs()) return;
int funcnum = 0;
int func_stmts = 0;
@ -223,8 +222,9 @@ private:
const int stmts = EmitCBaseCounterVisitor(itemp).count();
if (!funcp || (func_stmts + stmts) > v3Global.opt.outputSplitCFuncs()) {
// Make a new function
funcp = new AstCFunc{ofuncp->fileline(), ofuncp->name() + cvtToStr(++funcnum),
m_topScopep->scopep()};
funcp
= new AstCFunc{ofuncp->fileline(), ofuncp->name() + "__" + cvtToStr(funcnum++),
m_topScopep->scopep()};
funcp->dontCombine(true);
funcp->isStatic(false);
funcp->isLoose(true);

View File

@ -15,25 +15,21 @@ sub check_evals {
local $/; undef $/;
my $wholefile = <$fh>;
if ($wholefile =~ /___eval[0-9]+/) {
if ($wholefile =~ /___eval__[0-9]+\(.*\)\s*{/) {
++$got;
}
}
$got >= 3 or error("Too few _eval functions found: $got");
$got >= 2 or error("Too few _eval functions found: $got");
}
scenarios(vlt_all => 1);
compile(
v_flags2 => ["--output-split 1 --output-split-cfuncs 1 --exe ../$Self->{main_filename}"],
# verilator_make_gmake => 0,
);
# Very slow to compile, so generally skip it
execute(
check_finished => 1,
v_flags2 => ["--output-split 1 --output-split-cfuncs 20"],
verilator_make_gmake => 0, # Slow to compile, so skip it
);
check_evals();
ok(1);
1;

View File

@ -22,6 +22,14 @@ module t (/*AUTOARG*/
final if (cnt0 == 0) $stop;
final if (cnt1 != 0) $stop;
// Some dummy statements to make the code larger
generate
genvar i;
for (i = 0 ; i < 100; i = i + 1) begin
always @(posedge clk) $c("/*", i, "*/");
end
endgenerate
always_comb begin
if (cnt0==99) begin
$write("*-* All Finished *-*\n");