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

feat: separate DeadCodeElimPass, fix constant-folding of Modules #1897

Closed
wants to merge 6 commits into from

Conversation

acl-cqc
Copy link
Contributor

@acl-cqc acl-cqc commented Jan 29, 2025

  • Constant Folding now just breaks wires and inserts Const + LoadConst even for "unnecessary" (DCE-able) ops
  • Followup DCE pass removes these
  • DCE pass allows explicit specification of entry points for Module-rooted Hugrs
  • DCE pass takes an arbitrary callback for NodeDivergence aka "purity" - naming suggestions most welcome here

Could use more DCE-specific tests.

Thus, two in one:
closes #1797, #1807

Less efficient - we add constants for all ops to the Hugr, many of which we then DCE.

And, fails a test, because DCE doesn't have loop-termination results
@acl-cqc acl-cqc changed the title feat: separate DeadCodeElimPass from constant-folding, fix handling of Modules feat: separate DeadCodeElimPass, fix constant-folding of Modules Jan 29, 2025
Copy link

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 83.21678% with 24 lines in your changes missing coverage. Please review.

Project coverage is 86.52%. Comparing base (d6b8681) to head (595e82e).

Files with missing lines Patch % Lines
hugr-passes/src/dead_code.rs 80.00% 16 Missing ⚠️
hugr-passes/src/const_fold/test.rs 79.31% 0 Missing and 6 partials ⚠️
hugr-passes/src/const_fold.rs 95.45% 0 Missing and 1 partial ⚠️
hugr-passes/src/lib.rs 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1897      +/-   ##
==========================================
- Coverage   86.56%   86.52%   -0.05%     
==========================================
  Files         195      197       +2     
  Lines       35724    35794      +70     
  Branches    32537    32607      +70     
==========================================
+ Hits        30925    30971      +46     
- Misses       3012     3030      +18     
- Partials     1787     1793       +6     
Flag Coverage Δ
python 92.34% <ø> (ø)
rust 85.95% <83.21%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@acl-cqc
Copy link
Contributor Author

acl-cqc commented Feb 3, 2025

Merging with #1896

@acl-cqc acl-cqc closed this Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

constant folding: FuncDefns and FuncDecls are not considered needed
1 participant