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

Introduce recursive analysis via cycle finding in dependency graph. #5210

Merged
merged 3 commits into from
Dec 1, 2023

Conversation

tritao
Copy link
Contributor

@tritao tritao commented Oct 20, 2023

Description

This PR introduces a new recursive analysis pass, which is implemented for for regular and impl traits functions.

It works computing a dependency graph, and then running the Johnson graph cycle finding algorithm in the graph.

Regular functions still use the old recursive analysis pass due to issues with disabling the old dependency pass. When disabling the old recursion analysis code for regular functions, we get a stack overflow in the existing dependency map building code, which is shared with the existing type recursion analysis code.

Closes #4954.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@tritao tritao self-assigned this Oct 20, 2023
@tritao tritao added compiler General compiler. Should eventually become more specific as the issue is triaged compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen labels Oct 20, 2023
@tritao tritao force-pushed the recursive-calls branch 3 times, most recently from 373fc26 to 3476a65 Compare October 24, 2023 13:53
@tritao
Copy link
Contributor Author

tritao commented Oct 24, 2023

This approach still has a few problems, it's currently failing in a few more complex situations due to to the pass getting confused with tracking (non-)monomorphized ids. We'll need to better track between the original unmonorphized id and the monorphized ids. The CFG pass also had the same issue and we solved it by using the parents abstraction on the engines, but this was kinda of a temporary hack. Will be looking into a better way to track this.

@kodiamz-xbldr84
Copy link

kodiamz-xbldr84 commented Oct 24, 2023 via email

@tritao tritao force-pushed the recursive-calls branch 3 times, most recently from 5188dfd to df42ef6 Compare November 10, 2023 19:05
@tritao tritao changed the title Introduce recursive analysis via cycle finding in dependency graph. Introduce recursive analysis via cycle finding in dependency graph for impl traits functions. Nov 13, 2023
@tritao tritao marked this pull request as ready for review November 13, 2023 14:54
@tritao tritao requested a review from a team November 13, 2023 14:58
@tritao tritao marked this pull request as draft November 13, 2023 15:56
@tritao tritao force-pushed the recursive-calls branch 4 times, most recently from cb8b296 to 1b05581 Compare November 19, 2023 20:04
@tritao tritao changed the title Introduce recursive analysis via cycle finding in dependency graph for impl traits functions. Introduce recursive analysis via cycle finding in dependency graph. Nov 19, 2023
@tritao tritao marked this pull request as ready for review November 19, 2023 20:39
@IGI-111 IGI-111 requested a review from a team November 24, 2023 19:02
@tritao tritao enabled auto-merge (squash) December 1, 2023 17:49
@tritao tritao merged commit e70cb77 into FuelLabs:master Dec 1, 2023
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler General compiler. Should eventually become more specific as the issue is triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement recursion analysis for impl self method calls
5 participants