Fix false assertion failure on failed Dfg driver tracing (#6459)

This commit is contained in:
Geza Lore 2025-09-19 14:31:07 +02:00 committed by GitHub
parent c1ac2a79db
commit e24f84f713
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 10 deletions

View File

@ -176,45 +176,50 @@ class TraceDriver final : public DfgVisitor {
// Trace the vertex // Trace the vertex
onStackr = true; onStackr = true;
// The resulting driver that is not part of m_component
DfgVertex* resp = nullptr;
// If the currently traced vertex is in a different component, // If the currently traced vertex is in a different component,
// then we found what we were looking for. // then we found what we were looking for.
if (m_vtx2Scc[vtxp] != m_component) { if (m_vtx2Scc[vtxp] != m_component) {
m_resp = vtxp; resp = vtxp;
// If the result is a splice, we need to insert a temporary for it // If the result is a splice, we need to insert a temporary for it
// as a splice cannot be fed into arbitray logic // as a splice cannot be fed into arbitray logic
if (DfgVertexSplice* const splicep = m_resp->cast<DfgVertexSplice>()) { if (DfgVertexSplice* const splicep = resp->cast<DfgVertexSplice>()) {
DfgVertexVar* const tmpp = createTmp("TraceDriver", splicep); DfgVertexVar* const tmpp = createTmp("TraceDriver", splicep);
splicep->replaceWith(tmpp); splicep->replaceWith(tmpp);
tmpp->srcp(splicep); tmpp->srcp(splicep);
m_resp = tmpp; resp = tmpp;
} }
// Apply a Sel to extract the relevant bits if only a part is needed // Apply a Sel to extract the relevant bits if only a part is needed
if (msb != m_resp->width() - 1 || lsb != 0) { if (msb != resp->width() - 1 || lsb != 0) {
DfgSel* const selp = make<DfgSel>(m_resp, msb - lsb + 1); DfgSel* const selp = make<DfgSel>(resp, msb - lsb + 1);
selp->fromp(m_resp); selp->fromp(resp);
selp->lsb(lsb); selp->lsb(lsb);
m_resp = selp; resp = selp;
} }
} else { } else {
// Otherwise visit the vertex // Otherwise visit the vertex
VL_RESTORER(m_msb); VL_RESTORER(m_msb);
VL_RESTORER(m_lsb); VL_RESTORER(m_lsb);
VL_RESTORER(m_resp);
m_msb = msb; m_msb = msb;
m_lsb = lsb; m_lsb = lsb;
m_resp = nullptr; m_resp = nullptr;
iterate(vtxp); iterate(vtxp);
resp = m_resp;
} }
UASSERT_OBJ(!m_resp || m_resp->width() == (msb - lsb + 1), vtxp, "Wrong result width"); UASSERT_OBJ(!resp || resp->width() == (msb - lsb + 1), vtxp, "Wrong result width");
// Pop from stack // Pop from stack
onStackr = false; onStackr = false;
m_stack.pop_back(); m_stack.pop_back();
// Done // Done
if (!m_resp) { if (!resp) {
UINFO(9, "TraceDriver - Failed to trace vertex of type: " << vtxp->typeName()); UINFO(9, "TraceDriver - Failed to trace vertex of type: " << vtxp->typeName());
} }
return m_resp; return resp;
} }
template <typename Vertex> template <typename Vertex>