Skip to content

Conversation

@krame505
Copy link
Member

@krame505 krame505 commented Dec 21, 2025

Fix #907. Fix #909.

Changes

Massive flow analysis refactor. This fixes a hole in the flow analysis for tree sharing, in which dependencies in constructed productions on their children and children's syn attributes were not being considered in the sharing production. This yields more specific error messages than the "hidden transitive dependency" one in many cases, since we can now point to where a flow type is actually being exceeded, rather than "there may be a flow type exceeded somewhere". This change also somewhat improves the precision of the analysis for specifications that do not use sharing, as we can now more precisely determine the dependencies of a synthesized attribute on a tree, when we know by what production that tree was constructed.

Major changes

  • Introduce tile flow graphs for every production, containing additional eq vertices for the production lhs/rhs, but no nonterminal flowtype stitch points for the production RHS elements.
  • Introduce "outer equation" vertices, that separately track the dependencies needed to construct the outermost production in a tree (required when accessing an attributes), vs regular equation vertices that track the dependencies of constructing all subtrees of a tree (required when taking a reference.)
  • Introduce tile stitch points, that introduce edges corresponding to lhs and rhs vertices of a constructed production that has a decoration site vertex type.
  • Eliminate nonterminal flowtype stitch points for local/production/translation attributes. Instead, introduce nonterminal stitch points for holes, i.e. any expression that has a decoration site vertex type that is not a production application or use of tree sharing.
  • Refactor hidden transitive dependencies check.
  • Add an additional check, needed for soundness, that override equations (syn or inh) on extension dispatch implementation productions do not depend on any new vertices (not lhs inhs!) not depended upon in the host language tile graph for the dispatch.
  • Add conservative check for cycles due to missing inherited override equations on shared trees, disabled by default due to common patterns of forwarding violating this. Remove a previous more ad-hoc check for cycles specifically related to dispatching.
  • Some fixes to fully support arbitrary chains of translation attributes in flow types.
  • Refactor anonymous vertices, introducing a new vertex type for anon scrutinees.
  • Pattern variables now use subtree vertices instead of anon vertex types, as is done in my thesis. This means the special case checks for inhs being defined in remote equations are now covered by the existing decoration site tree resolution process.
  • Checking of anon decoration site and anon scrutinee inh vertex deps is now also covered in decoration site resolution.

Performance optimizations

  • Since all anon inh vertex deps are now checked in decoration site tree resolution, the checkAllEqDeps is no longer required and can be eliminated, substantially reducing the number of places we check for the presence of inherited equations (and query transitive dependencies.)
    • This also means we are now finding flow errors in a few places where we should have been using checkAllEqDeps, like action block code.
  • Reduce overhead of comparing flow vertices:
    • Redefine Ord/Eq on FlowVertex to compare a vertexName attribute, which is cached on the FlowVertex. String comparison is much faster than traversing a (now potentially deeply) nested VertexType tree.
    • Further reduce overhead of comparisons in graph operations by assigning a unique integer id to every globally unique FlowVertex (using a new IdCache library.) This allows for vertex comparisons to be done using a single integer comparison, instead of the potentially-long vertexName.

Note that there is not a huge amount of change in the performance of the analysis; the above-mentioned optimizations more or less offset the overhead of the increase the in size (and number) of flow graphs.

Other changes

  • Add foil to Jenkins downstream. It is now passing the flow analysis, with the sharing cycle check enabled.
  • Fix lots of flow errors discovered in the Silver compiler (and downstream) found in the course of this refactor.
  • Fix cycle crash due to comparing translation of action code in comparing interface files, by instead comparing the unparse to determine dirtiness.
  • Remove obsolete utilities
  • Add a few new things in the standard libraries
  • Error message improvements
  • Lots of other misc cleanup

Documentation

Updated comments, mostly. There actually aren't very many user-visible changes here, mostly just better (and more correct) error messages.

I'll try to update the website at some point to discuss the --warn-sharing-cycles flag.

Testing

Tested by finding new flow errors in the Silver compiler and downstream projects. Also added and updated a number of new tests in the testsuite.

…rtices in stitch points for constructed trees
…lar ones to avoid re-computation of stitch edges
… revert misguided changes to sig sharing stitch points and dec site resolution
…owup in flow graph sizes

This is somewhat less precise (and thus more conservative) than using tile stitch points for the entire tree, but in most cases shouldn't matter.
… decoration site tree resolution.

Not sure why this check was added originally.
… by the attr occurence, new check for extension dispatch impl override eqs, update tests
…n site vertex types, since they are decorated trees
…t for suppressed copy eq due to trans attr override on a forwarding prod
…ices for the equation deps of the outer tree node needed when accessing an attribute, and the full equation deps when taking a reference.

TODO: lhsEqVertex seems like the wrong way to deal with references to the LHS
Eliminate checkAllEqDeps and move all inh eq checks to reference/attr access expressions.  Also refactor handling of pattern match on a reference.

Currently, still has some bugs related to pattern variables, that also (ab)use anon vertex types.
@krame505 krame505 requested a review from ericvanwyk December 21, 2025 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant