Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspector: clear the done flag when revisiting node #4608

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

grg
Copy link
Contributor

@grg grg commented Apr 11, 2024

Set the done flag to false when revisiting a node in Tracker::try_start. Fixes a small regression introduced in #4447.

Without this fix, a Tofino pass errors out with an assertion failure from the Visitor infrastructure: Assertion current.depth < 10000' failed.` Without resetting the done flag in the tracker, the Inspector::apply_visitor method will always follow the "New or Revisit" path instead of the "Busy" path after a node has been visited once.

The associated test program mimics the Tofino pass that shows the problem.

@grg grg marked this pull request as ready for review April 11, 2024 03:10
@grg grg requested review from asl and vlstill April 11, 2024 03:10
@asl
Copy link
Contributor

asl commented Apr 11, 2024

@grg I think the code is similar here as with Visitor::ChangeTracker. Does it also have the same problem? Looks like Visitor::ChangeTracker::try_start is pretty much the same. However, it seems that it uses slightly different set of flags...

@fruffy fruffy added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Apr 11, 2024
Reset the done/visit_in_progress flag when revisiting a node in
Visitor::Tracker::try_start or Visitor::ChangeTracker::try_start.

For inspectors, fixes a small regression introduced in #4447. For
Modifiers/Transforms, fixes a bug that hadn't been previously
encountered. (Bug revealed by test program.)
@grg
Copy link
Contributor Author

grg commented Apr 11, 2024

@grg I think the code is similar here as with Visitor::ChangeTracker. Does it also have the same problem? Looks like Visitor::ChangeTracker::try_start is pretty much the same. However, it seems that it uses slightly different set of flags...

I've now applied the fix to Visitor::ChangeTracker::try_start after creating a second test case for Modifier and seeing the same issue. The issue existed with Modifier/Transform even before the refactoring in #4447, but no one must have encountered it.

I also took the opportunity to simplify the test case slightly. My original submission enabled joinFlows and used the ControlFlowVisitor, but experimentation showed that neither was necessary to hit the issue.

Copy link
Contributor

@asl asl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@grg grg added this pull request to the merge queue Apr 12, 2024
Merged via the queue into main with commit e0c4b8a Apr 12, 2024
17 checks passed
@grg grg deleted the grgibb/visitor_loop_fix branch April 12, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Topics concerning the core segments of the compiler (frontend, midend, parser)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants