Internals: Improve DFG implementation details (#6355)

Large scale refactoring to simplify some of the more obtuse internals of
DFG. Remove multiple redundant internal APIs, simplify representation of
variables, fix potential unsoundness in circular decomposition. No
functional change intended.
This commit is contained in:
Geza Lore
2025-09-02 16:50:40 +01:00
committed by GitHub
parent 67f26508ba
commit a6f26b85b3
24 changed files with 1763 additions and 1733 deletions
+4 -3
View File
@@ -55,7 +55,7 @@ class ColorStronglyConnectedComponents final {
const size_t rootIndex = vtxState.index = ++m_index;
// Visit children
vtx.forEachSink([&](DfgVertex& child) {
vtx.foreachSink([&](DfgVertex& child) {
VertexState& childSatate = child.user<VertexState>();
// If the child has not yet been visited, then continue traversal
if (childSatate.index == UNASSIGNED) visitColorSCCs(child, childSatate);
@@ -63,6 +63,7 @@ class ColorStronglyConnectedComponents final {
if (childSatate.component == UNASSIGNED) {
if (vtxState.index > childSatate.index) vtxState.index = childSatate.index;
}
return false;
});
if (vtxState.index == rootIndex) {
@@ -73,7 +74,7 @@ class ColorStronglyConnectedComponents final {
|| m_stack.back()->getUser<VertexState>().index < rootIndex;
// We also need a separate component for vertices that drive themselves (which can
// happen for input like 'assign a = a'), as we want to extract them (they are cyclic).
const bool drivesSelf = vtx.findSink<DfgVertex>([&vtx](const DfgVertex& sink) { //
const bool drivesSelf = vtx.foreachSink([&](const DfgVertex& sink) { //
return &vtx == &sink;
});
@@ -107,7 +108,7 @@ class ColorStronglyConnectedComponents final {
for (DfgVertexVar& vtx : m_dfg.varVertices()) {
VertexState& vtxState = vtx.user<VertexState>();
// If it has no input or no outputs, it cannot be part of a non-trivial SCC.
if (vtx.arity() == 0 || !vtx.hasSinks()) {
if ((!vtx.srcp() && !vtx.defaultp()) || !vtx.hasSinks()) {
UDEBUGONLY(UASSERT_OBJ(vtxState.index == UNASSIGNED || vtxState.component == 0,
&vtx, "Non circular variable must be in a trivial SCC"););
vtxState.index = 0;