fix: ConstantFold fails when the module contains function declarations#2954
fix: ConstantFold fails when the module contains function declarations#2954
Conversation
325fa4b to
c7432ea
Compare
| // Cannot prepopulate inputs for module-root; do not `join` with inputs explicitly specified. | ||
| continue; | ||
| } | ||
| if hugr.children(node).next().is_none() { |
There was a problem hiding this comment.
|| !hugr.get_optype(node).is_func_defn() on the previous?
There was a problem hiding this comment.
Or change node == hugr.module_root() to !OpTag.DataflowParent.is_superset(hugr.get_optype(node).tag()) ?
We assume that if it has no children, we cannot do constant-propagation on it....but that is not necessarily the case; inlining a Call preserves its interface. But I don't think there is any situation where a PassScope would have a Call in its preserve_interface except for the call being entrypoint, in which case constant-folding won't do anything.
There was a problem hiding this comment.
PassScope::preserve_interface states
Returns a list of nodes, in the subtree beneath [Self::root], for which the pass must preserve the observable semantics (ports, execution behaviour, linking).
That could technically return an arbitrary non-container node, and prepopulate_inputs would fail with any of them.
acl-cqc
left a comment
There was a problem hiding this comment.
Yah, gotta do something, and anything that makes that test not fail sounds good ;-).
(I'm a little skeptical of the "has no children" filter, it is common but it seems a bit of an abuse.)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2954 +/- ##
==========================================
+ Coverage 83.84% 83.85% +0.01%
==========================================
Files 267 267
Lines 52923 52966 +43
Branches 46854 46882 +28
==========================================
+ Hits 44371 44414 +43
Misses 6283 6283
Partials 2269 2269
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
## 🤖 New release * `hugr-model`: 0.26.0 -> 0.26.1 * `hugr-core`: 0.26.0 -> 0.26.1 (✓ API compatible changes) * `hugr-llvm`: 0.26.0 -> 0.26.1 * `hugr`: 0.26.0 -> 0.26.1 (✓ API compatible changes) * `hugr-passes`: 0.26.0 -> 0.26.1 (✓ API compatible changes) * `hugr-cli`: 0.26.0 -> 0.26.1 * `hugr-persistent`: 0.5.0 -> 0.5.1 <details><summary><i><b>Changelog</b></i></summary><p> ## `hugr-model` <blockquote> ## [0.26.0](hugr-model-v0.25.7...hugr-model-v0.26.0) - 2026-03-16 ### Testing - Replace model text snapshots with roundtrip tests ([#2933](#2933)) - Add missing width arg in model-call example ([#2945](#2945)) </blockquote> ## `hugr-core` <blockquote> ## [0.26.1](hugr-core-v0.26.0...hugr-core-v0.26.1) - 2026-03-18 ### New Features - *(hugr-py)* Allow linking packages and modules from Python ([#2947](#2947)) ### Refactor - start cleaning up SiblingSubgraph convexity checking ([#2956](#2956)) </blockquote> ## `hugr-llvm` <blockquote> ## [0.26.0](hugr-llvm-v0.25.7...hugr-llvm-v0.26.0) - 2026-03-16 ### New Features - *(llvm)* [**breaking**] Upgrade to LLVM 21 ([#2901](#2901)) - Include private HUGR functions in the local symbol table ([#2831](#2831)) - [**breaking**] TypeRow: add impl From array of Type, remove From<Type> ([#2784](#2784)) ### Refactor - [**breaking**] Remove deprecated Value::Function ([#2928](#2928)) - [**breaking**] Remove deprecated stack_array codegen ([#2929](#2929)) </blockquote> ## `hugr` <blockquote> ## [0.26.1](hugr-v0.26.0...hugr-v0.26.1) - 2026-03-18 ### Bug Fixes - ConstantFold fails when the module contains function declarations ([#2954](#2954)) ### New Features - *(hugr-py)* Allow linking packages and modules from Python ([#2947](#2947)) ### Refactor - start cleaning up SiblingSubgraph convexity checking ([#2956](#2956)) </blockquote> ## `hugr-passes` <blockquote> ## [0.26.1](hugr-passes-v0.26.0...hugr-passes-v0.26.1) - 2026-03-18 ### Bug Fixes - ConstantFold fails when the module contains function declarations ([#2954](#2954)) </blockquote> ## `hugr-cli` <blockquote> ## [0.26.0](hugr-cli-v0.25.7...hugr-cli-v0.26.0) - 2026-03-16 ### Documentation - Move `spec/schema` and `spec/std_extensions` to `resources/` ([#2897](#2897)) ### New Features - [**breaking**] Rename ModelText envelope format to SExpression ([#2927](#2927)) - [**breaking**] TypeRow: add impl From array of Type, remove From<Type> ([#2784](#2784)) </blockquote> ## `hugr-persistent` <blockquote> ## [0.5.0](hugr-persistent-v0.4.7...hugr-persistent-v0.5.0) - 2026-03-16 ### New Features - *(llvm)* [**breaking**] Upgrade to LLVM 21 ([#2901](#2901)) - [**breaking**] TypeRow: add impl From array of Type, remove From<Type> ([#2784](#2784)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/).
Updates the hugr dependencies to `0.26.0`, and fixes all the breaking changes. I only added no-op stubs implementing `WithScope` for the local passes. We will add the actual implementation in #1429. Requires updating LLVM too, so we should merge #1422 into this PR. We also need to delete the now removed `stack_array` lowering. BREAKING CHANGE: Updated public `hugr` dependency to `0.26.0`. Requires a `hugr-passes 0.26.1` patch release to include Quantinuum/hugr#2954 --------- Co-authored-by: George Hodgkins <[email protected]> Co-authored-by: Jake Arkinstall <[email protected]>
No description provided.