mirror of
https://github.com/verilator/verilator.git
synced 2026-09-02 18:58:51 +02:00
Add UNUSEDLOOP when unused loop is removed (#4926)
This commit is contained in:
@@ -1312,6 +1312,18 @@ class GateUnused final {
|
||||
}
|
||||
}
|
||||
|
||||
static void warnUnused(const AstNode* const nodep) {
|
||||
if (nodep->fileline()->warnIsOff(V3ErrorCode::UNUSEDLOOP)) return;
|
||||
|
||||
if (const AstNodeProcedure* const procedurep = VN_CAST(nodep, NodeProcedure)) {
|
||||
if (procedurep->stmtsp())
|
||||
procedurep->stmtsp()->foreach([](const AstWhile* const whilep) { //
|
||||
whilep->v3warn(UNUSEDLOOP, "Loop is not used and will be optimized out");
|
||||
whilep->fileline()->modifyWarnOff(V3ErrorCode::UNUSEDLOOP, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Remove unused logic
|
||||
void remove() {
|
||||
for (V3GraphVertex *vtxp = m_graph.verticesBeginp(), *nextp; vtxp; vtxp = nextp) {
|
||||
@@ -1319,6 +1331,8 @@ class GateUnused final {
|
||||
if (GateLogicVertex* const lVtxp = vtxp->cast<GateLogicVertex>()) {
|
||||
if (!lVtxp->consumed() && lVtxp->activep()) { // activep is nullptr under cfunc
|
||||
AstNode* const nodep = lVtxp->nodep();
|
||||
warnUnused(nodep);
|
||||
|
||||
UINFO(8, " Remove unconsumed " << nodep << endl);
|
||||
nodep->unlinkFrBack();
|
||||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||
|
||||
Reference in New Issue
Block a user