Skip to content

Conversation

@acl-cqc
Copy link
Contributor

@acl-cqc acl-cqc commented Oct 28, 2025

Breaking followup to #2633.

  • normalize_cfgs moves the entry block outside the CFG even if there are outgoing Dom edges by inlining the DFG (so the entry block children become siblings of the CFG), as this makes said edges into valid Ext edges.

Sadly, I don't see a good/corresponding treatment for the exit dfg; it doesn't help that the source block of the Dom edges must dominate the exit (and hence we could break the CFG just before that source block and start another CFG), because even then there could be backedges to the source (new CFG entry) block, so we can't necessarily lift it outside. Options thus seem to be:

  1. thread the values from the source block through the whole CFG
  2. add extra outputs to the CFG, and thus to each predecessor of the new exit block - but that requires either finding the corresponding Tag, or also adding new inputs to any other successors of those predecessors (and any other predecessors of those, and so on)

...and I've not tried either of those here.

BREAKING CHANGE: NormalizeCFGResult specifies entry_nodes_moved not entry_dfg (as no DFG is inserted).

@acl-cqc acl-cqc changed the title feat!(hugr-passes): ReplaceTypes on whole Hugr, normalize_cfgs inlines entry DFG feat(hugr-passes)!: ReplaceTypes on whole Hugr, normalize_cfgs inlines entry DFG Oct 28, 2025
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.41%. Comparing base (8b34d5d) to head (54e39dd).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2649      +/-   ##
==========================================
+ Coverage   83.40%   83.41%   +0.01%     
==========================================
  Files         262      262              
  Lines       51135    51176      +41     
  Branches    46696    46737      +41     
==========================================
+ Hits        42648    42691      +43     
+ Misses       6109     6107       -2     
  Partials     2378     2378              
Flag Coverage Δ
python 91.46% <ø> (ø)
rust 82.65% <100.00%> (+0.01%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from acl/validate_outside_entry to main October 28, 2025 18:50
@hugrbot
Copy link
Collaborator

hugrbot commented Oct 28, 2025

This PR contains breaking changes to the public Rust API.

cargo-semver-checks summary
    Building hugr v0.24.1 (current)
     Built [  21.033s] (current)
   Parsing hugr v0.24.1 (current)
    Parsed [   0.004s] (current)
  Building hugr v0.24.1 (baseline)
     Built [  21.120s] (baseline)
   Parsing hugr v0.24.1 (baseline)
    Parsed [   0.004s] (baseline)
  Checking hugr v0.24.1 -> v0.24.1 (assume minor change)
   Checked [   0.011s] 159 checks: 159 pass, 41 skip
   Summary no semver update required
  Finished [  43.645s] hugr
  Building hugr-cli v0.24.1 (current)
     Built [  19.643s] (current)
   Parsing hugr-cli v0.24.1 (current)
    Parsed [   0.008s] (current)
  Building hugr-cli v0.24.1 (baseline)
     Built [  19.653s] (baseline)
   Parsing hugr-cli v0.24.1 (baseline)
    Parsed [   0.009s] (baseline)
  Checking hugr-cli v0.24.1 -> v0.24.1 (assume minor change)
   Checked [   0.013s] 159 checks: 159 pass, 41 skip
   Summary no semver update required
  Finished [  41.039s] hugr-cli
  Building hugr-core v0.24.1 (current)
     Built [  15.328s] (current)
   Parsing hugr-core v0.24.1 (current)
    Parsed [   0.074s] (current)
  Building hugr-core v0.24.1 (baseline)
     Built [  15.631s] (baseline)
   Parsing hugr-core v0.24.1 (baseline)
    Parsed [   0.071s] (baseline)
  Checking hugr-core v0.24.1 -> v0.24.1 (assume minor change)
   Checked [   0.149s] 159 checks: 159 pass, 41 skip
   Summary no semver update required
  Finished [  32.439s] hugr-core
  Building hugr-llvm v0.24.1 (current)
     Built [  14.572s] (current)
   Parsing hugr-llvm v0.24.1 (current)
    Parsed [   0.011s] (current)
  Building hugr-llvm v0.24.1 (baseline)
     Built [  14.718s] (baseline)
   Parsing hugr-llvm v0.24.1 (baseline)
    Parsed [   0.011s] (baseline)
  Checking hugr-llvm v0.24.1 -> v0.24.1 (assume minor change)
   Checked [   0.031s] 159 checks: 159 pass, 41 skip
   Summary no semver update required
  Finished [  30.579s] hugr-llvm
  Building hugr-model v0.24.1 (current)
     Built [   5.008s] (current)
   Parsing hugr-model v0.24.1 (current)
    Parsed [   0.015s] (current)
  Building hugr-model v0.24.1 (baseline)
     Built [   5.091s] (baseline)
   Parsing hugr-model v0.24.1 (baseline)
    Parsed [   0.014s] (baseline)
  Checking hugr-model v0.24.1 -> v0.24.1 (assume minor change)
   Checked [   0.025s] 159 checks: 159 pass, 41 skip
   Summary no semver update required
  Finished [  11.067s] hugr-model
  Building hugr-passes v0.24.1 (current)
     Built [  14.858s] (current)
   Parsing hugr-passes v0.24.1 (current)
    Parsed [   0.024s] (current)
  Building hugr-passes v0.24.1 (baseline)
     Built [  14.863s] (baseline)
   Parsing hugr-passes v0.24.1 (baseline)
    Parsed [   0.023s] (baseline)
  Checking hugr-passes v0.24.1 -> v0.24.1 (assume minor change)
   Checked [   0.028s] 159 checks: 157 pass, 2 fail, 0 warn, 41 skip

--- failure enum_struct_variant_field_added: pub enum struct variant field added ---

Description:
An enum's exhaustive struct variant has a new field, which has to be included when constructing or matching on this variant.
      ref: https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.45.0/src/lints/enum_struct_variant_field_added.ron

Failed in:
field entry_nodes_moved of variant NormalizeCFGResult::CFGPreserved in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-passes/src/normalize_cfgs.rs:89

--- failure enum_struct_variant_field_missing: pub enum struct variant's field removed or renamed ---

Description:
A publicly-visible enum has a struct variant whose field is no longer available under its prior name. It may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.45.0/src/lints/enum_struct_variant_field_missing.ron

Failed in:
field entry_dfg of variant NormalizeCFGResult::CFGPreserved, previously in file /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-passes/src/normalize_cfgs.rs:88

   Summary semver requires new major version: 2 major and 0 minor checks failed
  Finished [  31.031s] hugr-passes
  Building hugr-persistent v0.3.2 (current)
     Built [  11.706s] (current)
   Parsing hugr-persistent v0.3.2 (current)
    Parsed [   0.007s] (current)
  Building hugr-persistent v0.3.2 (baseline)
     Built [  11.592s] (baseline)
   Parsing hugr-persistent v0.3.2 (baseline)
    Parsed [   0.007s] (baseline)
  Checking hugr-persistent v0.3.2 -> v0.3.2 (assume minor change)
   Checked [   0.013s] 159 checks: 159 pass, 41 skip
   Summary no semver update required
  Finished [  24.431s] hugr-persistent

@acl-cqc acl-cqc marked this pull request as ready for review October 28, 2025 20:18
@acl-cqc acl-cqc requested a review from a team as a code owner October 28, 2025 20:18
@acl-cqc acl-cqc requested a review from lmondada October 28, 2025 20:18
@acl-cqc acl-cqc changed the title feat(hugr-passes)!: ReplaceTypes on whole Hugr, normalize_cfgs inlines entry DFG feat(hugr-passes)!: normalize_cfgs inlines entry DFG Nov 3, 2025
@acl-cqc acl-cqc requested review from croyzor and removed request for lmondada November 3, 2025 14:47
@acl-cqc
Copy link
Contributor Author

acl-cqc commented Nov 3, 2025

@croyzor I picked you because you were randomly picked for #2662 after Seyon had already stepped in, so remembering the lost roll of the dice ;)

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.

3 participants