Add DFG 'regularize' pass, and improve variable removal (#4937)

This functionality used to be distributed in the removeVars pass and the
final dfgToAst conversion. Instead added a new 'regularize' pass to
convert DFGs into forms that can be trivially converted back to Ast, and
a new 'eliminateVars' pass to remove/repalce redundant variables. This
simplifies dfgToAst significantly and makes the code a bit easier to
follow.

The new 'regularize' pass will ensure that every sub-expression with
multiple uses is assigned to a temporary (unless it's a trivial memory
reference or constant), and will also eliminate or replace redundant
variables. Overall it is a performance neutral change but it does
enable some later improvements which required the graph to be in this
form, and this also happens to be the form required for the dfgToAst
conversion.
This commit is contained in:
Geza Lore
2024-03-02 19:49:29 +00:00
committed by GitHub
parent 0ec32ee404
commit 5e1fc6e24d
16 changed files with 360 additions and 328 deletions
+5 -3
View File
@@ -329,11 +329,13 @@ class ExtractCyclicComponents final {
clonep = new DfgVarArray{m_dfg, aVtxp->varp()};
}
UASSERT_OBJ(clonep, &vtx, "Unhandled 'DfgVertexVar' sub-type");
if (vtx.hasModRefs()) clonep->setHasModRefs();
if (vtx.hasExtRefs()) clonep->setHasExtRefs();
VertexState& cloneStatep = allocState(*clonep);
cloneStatep.component = component;
// We need to mark both the original and the clone as having additional references
vtx.setHasModRefs();
clonep->setHasModRefs();
// We need to mark both the original and the clone as having references in other DFGs
vtx.setHasDfgRefs();
clonep->setHasDfgRefs();
}
return *clonep;
}