Fix multple function definitions in V3Sched (#4416).
This commit is contained in:
parent
9eba61018a
commit
5447ed2629
1
Changes
1
Changes
|
|
@ -13,6 +13,7 @@ Verilator 5.015 devel
|
||||||
|
|
||||||
**Minor:**
|
**Minor:**
|
||||||
|
|
||||||
|
* Fix multple function definitions in V3Sched (#4416). [Hennadii Chernyshchyk]
|
||||||
|
|
||||||
|
|
||||||
Verilator 5.014 2023-08-06
|
Verilator 5.014 2023-08-06
|
||||||
|
|
|
||||||
|
|
@ -119,29 +119,29 @@ void invertAndMergeSenTreeMap(
|
||||||
//============================================================================
|
//============================================================================
|
||||||
// Split large function according to --output-split-cfuncs
|
// Split large function according to --output-split-cfuncs
|
||||||
|
|
||||||
|
std::map<AstCFunc*, int> s_funcNums; // What split number to attach to a function
|
||||||
|
|
||||||
|
AstCFunc* splitCheckCreateNewSubFunc(AstCFunc* ofuncp) {
|
||||||
|
auto funcNumItMatch = s_funcNums.emplace(std::make_pair(ofuncp, 0));
|
||||||
|
AstCFunc* const subFuncp = new AstCFunc{
|
||||||
|
ofuncp->fileline(), ofuncp->name() + "__" + cvtToStr(funcNumItMatch.first->second++),
|
||||||
|
ofuncp->scopep()};
|
||||||
|
subFuncp->dontCombine(true);
|
||||||
|
subFuncp->isStatic(false);
|
||||||
|
subFuncp->isLoose(true);
|
||||||
|
subFuncp->slow(ofuncp->slow());
|
||||||
|
subFuncp->declPrivate(ofuncp->declPrivate());
|
||||||
|
return subFuncp;
|
||||||
|
};
|
||||||
|
|
||||||
void splitCheck(AstCFunc* ofuncp) {
|
void splitCheck(AstCFunc* ofuncp) {
|
||||||
if (!v3Global.opt.outputSplitCFuncs() || !ofuncp->stmtsp()) return;
|
if (!v3Global.opt.outputSplitCFuncs() || !ofuncp->stmtsp()) return;
|
||||||
if (ofuncp->nodeCount() < v3Global.opt.outputSplitCFuncs()) return;
|
if (ofuncp->nodeCount() < v3Global.opt.outputSplitCFuncs()) return;
|
||||||
|
|
||||||
int funcnum = 0;
|
|
||||||
int func_stmts = 0;
|
int func_stmts = 0;
|
||||||
const bool is_ofuncp_coroutine = ofuncp->isCoroutine();
|
const bool is_ofuncp_coroutine = ofuncp->isCoroutine();
|
||||||
AstCFunc* funcp = nullptr;
|
AstCFunc* funcp = nullptr;
|
||||||
|
|
||||||
const auto createNewSubFuncp = [&]() {
|
|
||||||
AstCFunc* const subFuncp = new AstCFunc{
|
|
||||||
ofuncp->fileline(), ofuncp->name() + "__" + cvtToStr(funcnum++), ofuncp->scopep()};
|
|
||||||
subFuncp->dontCombine(true);
|
|
||||||
subFuncp->isStatic(false);
|
|
||||||
subFuncp->isLoose(true);
|
|
||||||
subFuncp->slow(ofuncp->slow());
|
|
||||||
subFuncp->declPrivate(ofuncp->declPrivate());
|
|
||||||
|
|
||||||
func_stmts = 0;
|
|
||||||
|
|
||||||
return subFuncp;
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto finishSubFuncp = [&](AstCFunc* subFuncp) {
|
const auto finishSubFuncp = [&](AstCFunc* subFuncp) {
|
||||||
ofuncp->scopep()->addBlocksp(subFuncp);
|
ofuncp->scopep()->addBlocksp(subFuncp);
|
||||||
AstCCall* const callp = new AstCCall{subFuncp->fileline(), subFuncp};
|
AstCCall* const callp = new AstCCall{subFuncp->fileline(), subFuncp};
|
||||||
|
|
@ -160,7 +160,8 @@ void splitCheck(AstCFunc* ofuncp) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
funcp = createNewSubFuncp();
|
funcp = splitCheckCreateNewSubFunc(ofuncp);
|
||||||
|
func_stmts = 0;
|
||||||
|
|
||||||
// Unlink all statements, then add item by item to new sub-functions
|
// Unlink all statements, then add item by item to new sub-functions
|
||||||
AstBegin* const tempp = new AstBegin{ofuncp->fileline(), "[EditWrapper]",
|
AstBegin* const tempp = new AstBegin{ofuncp->fileline(), "[EditWrapper]",
|
||||||
|
|
@ -173,7 +174,8 @@ void splitCheck(AstCFunc* ofuncp) {
|
||||||
|
|
||||||
if ((func_stmts + stmts) > v3Global.opt.outputSplitCFuncs()) {
|
if ((func_stmts + stmts) > v3Global.opt.outputSplitCFuncs()) {
|
||||||
finishSubFuncp(funcp);
|
finishSubFuncp(funcp);
|
||||||
funcp = createNewSubFuncp();
|
funcp = splitCheckCreateNewSubFunc(ofuncp);
|
||||||
|
func_stmts = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
funcp->addStmtsp(itemp);
|
funcp->addStmtsp(itemp);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue