diff --git a/src/V3Dfg.cpp b/src/V3Dfg.cpp index a619ee9a7..e57f5095c 100644 --- a/src/V3Dfg.cpp +++ b/src/V3Dfg.cpp @@ -407,41 +407,6 @@ void DfgGraph::dumpDotFilePrefixed(const string& label) const { dumpDotFile(v3Global.debugFilename(filename) + ".dot", label); } -// Dump upstream logic cone starting from given vertex -static void dumpDotUpstreamConeFromVertex(std::ostream& os, const DfgVertex& vtx) { - // Work queue for depth first traversal starting from this vertex - std::vector queue{&vtx}; - - // Set of already visited vertices - std::unordered_set visited; - - // Depth first traversal - while (!queue.empty()) { - // Pop next work item - const DfgVertex* const itemp = queue.back(); - queue.pop_back(); - - // Mark vertex as visited - const bool isFirstEncounter = visited.insert(itemp).second; - - // If we have already visited this vertex during the traversal, then move on. - if (!isFirstEncounter) continue; - - // Enqueue all sources of this vertex. - itemp->forEachSource([&](const DfgVertex& src) { queue.push_back(&src); }); - - // Emit this vertex and all of its source edges - dumpDotVertexAndSourceEdges(os, *itemp); - } - - // Emit all DfgVarPacked vertices that have external references driven by this vertex - vtx.forEachSink([&](const DfgVertex& dst) { - if (const DfgVarPacked* const varVtxp = dst.cast()) { - if (varVtxp->hasNonLocalRefs()) dumpDotVertexAndSourceEdges(os, dst); - } - }); -} - // LCOV_EXCL_START // Debug function for developer use only void DfgGraph::dumpDotUpstreamCone(const string& fileName, const DfgVertex& vtx, const string& name) const { @@ -454,8 +419,30 @@ void DfgGraph::dumpDotUpstreamCone(const string& fileName, const DfgVertex& vtx, if (!name.empty()) *os << "graph [label=\"" << name << "\", labelloc=t, labeljust=l]\n"; *os << "graph [rankdir=LR]\n"; - // Dump the cone - dumpDotUpstreamConeFromVertex(*os, vtx); + // Work queue for depth first traversal starting from this vertex + std::vector queue{&vtx}; + + // Set of already visited vertices + std::unordered_set visited; + + // Depth first traversal + while (!queue.empty()) { + // Pop next work item + const DfgVertex* const vtxp = queue.back(); + queue.pop_back(); + + // Mark vertex as visited + const bool isFirstEncounter = visited.insert(vtxp).second; + + // If we have already visited this vertex during the traversal, then move on. + if (!isFirstEncounter) continue; + + // Enqueue all sources of this vertex. + vtxp->forEachSource([&](const DfgVertex& src) { queue.push_back(&src); }); + + // Emit this vertex and all of its source edges + dumpDotVertexAndSourceEdges(*os, *vtxp); + } // Footer *os << "}\n"; @@ -465,40 +452,6 @@ void DfgGraph::dumpDotUpstreamCone(const string& fileName, const DfgVertex& vtx, } // LCOV_EXCL_STOP -void DfgGraph::dumpDotAllVarConesPrefixed(const string& label) const { - const string prefix = label.empty() ? name() + "-cone-" : name() + "-" + label + "-cone-"; - forEachVertex([&](const DfgVertex& vtx) { - // Check if this vertex drives a variable referenced outside the DFG. - const DfgVarPacked* const sinkp - = vtx.findSink([](const DfgVarPacked& sink) { // - return sink.hasNonLocalRefs(); - }); - - // We only dump cones driving an externally referenced variable - if (!sinkp) return; - - // Open output file - const string coneName{prefix + sinkp->nodep()->name()}; - const string fileName{v3Global.debugFilename(coneName) + ".dot"}; - const std::unique_ptr os{V3File::new_ofstream(fileName)}; - if (os->fail()) v3fatal("Can't write file: " << fileName); - - // Header - *os << "digraph dfg {\n"; - *os << "graph [label=\"" << coneName << "\", labelloc=t, labeljust=l]\n"; - *os << "graph [rankdir=LR]\n"; - - // Dump this cone - dumpDotUpstreamConeFromVertex(*os, vtx); - - // Footer - *os << "}\n"; - - // Done with this logic cone - os->close(); - }); -} - //------------------------------------------------------------------------------ // DfgEdge //------------------------------------------------------------------------------ diff --git a/src/V3Dfg.h b/src/V3Dfg.h index cef0b5e72..6af0531ee 100644 --- a/src/V3Dfg.h +++ b/src/V3Dfg.h @@ -756,11 +756,6 @@ public: // 'filename'. 'name' is the name of the graph, which is included in the output. void dumpDotUpstreamCone(const string& filename, const DfgVertex& vtx, const string& name = "") const VL_MT_DISABLED; - // Dump all individual logic cones driving external variables in Graphviz format into separate - // new automatically numbered debug files. 'label' is added to the name of the graph, which is - // included in the file names and the output. This is useful for very large graphs that are - // otherwise difficult to browse visually due to their size. - void dumpDotAllVarConesPrefixed(const string& label = "") const VL_MT_DISABLED; }; // Specializations of privateTypeTest diff --git a/src/V3DfgPasses.cpp b/src/V3DfgPasses.cpp index d349551d4..9a9058090 100644 --- a/src/V3DfgPasses.cpp +++ b/src/V3DfgPasses.cpp @@ -523,7 +523,6 @@ void V3DfgPasses::optimize(DfgGraph& dfg, V3DfgContext& ctx) { ++passNumber; }; - if (dumpDfgLevel() >= 8) dfg.dumpDotAllVarConesPrefixed(ctx.prefix() + "input"); apply(3, "input ", [&]() {}); apply(4, "inlineVars ", [&]() { inlineVars(dfg); }); apply(4, "cse0 ", [&]() { cse(dfg, ctx.m_cseContext0); }); @@ -538,5 +537,4 @@ void V3DfgPasses::optimize(DfgGraph& dfg, V3DfgContext& ctx) { // Accumulate patterns for reporting if (v3Global.opt.stats()) ctx.m_patternStats.accumulate(dfg); apply(4, "regularize", [&]() { regularize(dfg, ctx.m_regularizeContext); }); - if (dumpDfgLevel() >= 8) dfg.dumpDotAllVarConesPrefixed(ctx.prefix() + "optimized"); }