Skip to content

Conversation

@acl-cqc
Copy link
Contributor

@acl-cqc acl-cqc commented Nov 4, 2025

fixes CQCL/guppylang#1330

This is a mass of Hugr construction; the alternative of adding a new op to BorrowArray would do much the same in LLVM, and I don't think the increase in Hugr size should be very much - compared to a standard linear array discard, we have TailLoop rather than ArrayScan, with merely an extra conditional around the discarding of each element (and nodes moved into the main Hugr rather than a Value::Function, so it looks bigger).

Note there is no need to do this for BorrowArray::discard (the copyable-elements-only function), as that doesn't check borrowedness; copyable elements don't need discard functions so we just deallocate the lot without looking what's there.

I added hugr-passes as a dev dependency of hugr-llvm to get an execution test, and verified switching-round the senses of conditionals made this fail, which gives some confidence it's correct ;)

@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.46%. Comparing base (3d1ea85) to head (d3cb7fc).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2666      +/-   ##
==========================================
+ Coverage   83.41%   83.46%   +0.04%     
==========================================
  Files         262      262              
  Lines       51176    51297     +121     
  Branches    46737    46858     +121     
==========================================
+ Hits        42689    42813     +124     
+ Misses       6109     6105       -4     
- Partials     2378     2379       +1     
Flag Coverage Δ
python 91.46% <ø> (ø)
rust 82.70% <100.00%> (+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.

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

@acl-cqc acl-cqc force-pushed the acl/drop_part_borrowed branch 2 times, most recently from 1972949 to d4e9638 Compare November 4, 2025 19:46
@acl-cqc acl-cqc force-pushed the acl/drop_part_borrowed branch from d4e9638 to de750c8 Compare November 4, 2025 19:48
@acl-cqc acl-cqc marked this pull request as ready for review November 4, 2025 20:06
@acl-cqc acl-cqc requested a review from a team as a code owner November 4, 2025 20:06
@acl-cqc acl-cqc requested a review from mark-koch November 4, 2025 20:06
Copy link
Collaborator

@aborgna-q aborgna-q left a comment

Choose a reason for hiding this comment

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

I had to add hugr-passes as a dev dependency of hugr-llvm

Should be fine, It makes more sense than testing llvm code on hugr-passes. If needed, we can move things to integration tests later.

I suggest we make the "drop" op public as part of some hugr-passes extension

Maybe open an issue?

@acl-cqc acl-cqc enabled auto-merge November 5, 2025 17:06
@acl-cqc acl-cqc added this pull request to the merge queue Nov 5, 2025
Merged via the queue into main with commit 7287845 Nov 5, 2025
40 checks passed
@acl-cqc acl-cqc deleted the acl/drop_part_borrowed branch November 5, 2025 17:11
@hugrbot hugrbot mentioned this pull request Nov 5, 2025
@hugrbot hugrbot mentioned this pull request Nov 6, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 6, 2025
## 🤖 New release

* `hugr-model`: 0.24.2 -> 0.24.3 (✓ API compatible changes)
* `hugr-core`: 0.24.2 -> 0.24.3
* `hugr-llvm`: 0.24.2 -> 0.24.3 (✓ API compatible changes)
* `hugr-passes`: 0.24.2 -> 0.24.3 (✓ API compatible changes)
* `hugr`: 0.24.2 -> 0.24.3 (✓ API compatible changes)
* `hugr-cli`: 0.24.2 -> 0.24.3 (✓ API compatible changes)
* `hugr-persistent`: 0.3.3 -> 0.3.4

<details><summary><i><b>Changelog</b></i></summary><p>

## `hugr-model`

<blockquote>

##
[0.24.1](hugr-model-v0.24.0...hugr-model-v0.24.1)
- 2025-11-03

### Bug Fixes

- Correct conversion of `table::Term::Tuple` to `ast::Term`
([#2653](#2653))
</blockquote>

## `hugr-core`

<blockquote>

##
[0.24.1](hugr-core-v0.24.0...hugr-core-v0.24.1)
- 2025-11-03

### Bug Fixes

- validation outside entrypoint, normalize_cfgs w/ nonlocal edges
([#2633](#2633))
- SiblingSubgraph::try_from_nodes for non-entrypoint region
([#2655](#2655))
- Correct conversion of `table::Term::Tuple` to `ast::Term`
([#2653](#2653))

### New Features

- track package descriptions when loading
([#2639](#2639))
- *(cli)* describe sub-command
([#2650](#2650))
</blockquote>

## `hugr-llvm`

<blockquote>

##
[0.24.3](hugr-llvm-v0.24.2...hugr-llvm-v0.24.3)
- 2025-11-06

### Bug Fixes

- BorrowArray discard handler allows elements to be borrowed
([#2666](#2666))
</blockquote>

## `hugr-passes`

<blockquote>

##
[0.24.3](hugr-passes-v0.24.2...hugr-passes-v0.24.3)
- 2025-11-06

### Bug Fixes

- BorrowArray discard handler allows elements to be borrowed
([#2666](#2666))
</blockquote>

## `hugr`

<blockquote>

##
[0.24.3](hugr-v0.24.2...hugr-v0.24.3)
- 2025-11-06

### Bug Fixes

- BorrowArray discard handler allows elements to be borrowed
([#2666](#2666))
</blockquote>

## `hugr-cli`

<blockquote>

##
[0.24.1](hugr-cli-v0.24.0...hugr-cli-v0.24.1)
- 2025-11-03

### New Features

- track package descriptions when loading
([#2639](#2639))
- *(cli)* describe sub-command
([#2650](#2650))
</blockquote>

## `hugr-persistent`

<blockquote>

##
[0.3.2](hugr-persistent-v0.3.1...hugr-persistent-v0.3.2)
- 2025-11-03

### New Features

- *(persistent)* More efficient HugrView iterators for PersistentHugr
([#2595](#2595))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
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.

Runtime panic upon early return when iterating through array of affine/bool

3 participants