Skip to content

✨ Let QCOProgramBuilder build additional functions and call them - #2196

Open
DRovara wants to merge 1 commit into
mlir/call-aware-iteratorsfrom
mlir/builder-call-support
Open

✨ Let QCOProgramBuilder build additional functions and call them#2196
DRovara wants to merge 1 commit into
mlir/call-aware-iteratorsfrom
mlir/builder-call-support

Conversation

@DRovara

@DRovara DRovara commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

Description

Third of a stack replacing #1970. Builds on #2194.

startFunction and endFunction build private helper functions, while call
emits calls to them and transfers the builder's linear-value tracking across
the boundary.

Helper functions must be completed before operations are added to main. No
production consumer in this stack needs to suspend a partially built main, so
this ordering rule replaces copied caller tracking sets and a function-scope
abstraction with one saved insertion point. It also prevents helper bodies from
capturing values created in main.

At a call, qubit and qubit-tensor operands are paired with the results that
actually continue them using the mappings from #2194. Values kept by the callee
are consumed, results without a continuing operand are newly tracked, and
classical values pass through without linear tracking. Unsupported callee
shapes fail closed.

Simplification audit

The Ponytail review combined operand preparation and validation, unified result
tracking, removed duplicated function-scope state, and deleted a tensor-swap
test that could not distinguish derived from positional pairing. The focused
tests retain each observable success and failure contract.

Testing

  • 9 builder-focused tests pass.
  • All 492 QCO IR tests pass.
  • The release build and all 3,923 configured tests pass on the final stack, with
    one expected skip.
  • uvx nox -s cpp-lint and uvx nox -s lint pass.

AI assistance

Code and this description were produced with Claude Code (Opus 5) and Codex,
acting on my instructions and within the scope I authorized.

Checklist

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed).
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

If PR contains AI-assisted content:

  • Any agent that created, edited, or submitted GitHub content was explicitly authorized for that scope, as required by our AI Usage Guidelines.
  • Every agent-authored or agent-edited public text body begins with the visible disclosure 🤖 *AI text below* 🤖 (titles are exempt).
  • I have disclosed AI assistance in the PR description.
  • I confirm that I have personally reviewed and understood all AI-generated content, and accept full responsibility for it.

@DRovara
DRovara force-pushed the mlir/builder-call-support branch 2 times, most recently from 8b58076 to 6e146d2 Compare August 24, 2026 09:33
@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.27273% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
mlir/lib/Dialect/QCO/Builder/QCOProgramBuilder.cpp 97.2% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@DRovara
DRovara force-pushed the mlir/builder-call-support branch from 6e146d2 to 1079b35 Compare August 24, 2026 09:52
@DRovara
DRovara force-pushed the mlir/builder-call-support branch 3 times, most recently from dbe18b6 to 4a8041f Compare August 25, 2026 10:48
@burgholzer
burgholzer force-pushed the mlir/builder-call-support branch from 4a8041f to a91b5cd Compare August 25, 2026 21:44
@DRovara
DRovara force-pushed the mlir/builder-call-support branch from a91b5cd to 1978be0 Compare August 26, 2026 14:08
@DRovara
DRovara force-pushed the mlir/builder-call-support branch 2 times, most recently from 32e9dba to 14a7cfa Compare August 26, 2026 14:34
@DRovara
DRovara marked this pull request as ready for review August 26, 2026 14:37
@DRovara
DRovara force-pushed the mlir/builder-call-support branch from 14a7cfa to 7e8879c Compare August 27, 2026 11:40
@DRovara
DRovara force-pushed the mlir/builder-call-support branch from 7e8879c to 7a47486 Compare August 27, 2026 13:16
@DRovara
DRovara requested a review from burgholzer August 28, 2026 07:17
@DRovara
DRovara force-pushed the mlir/builder-call-support branch 2 times, most recently from 03b4435 to db2ac3b Compare August 28, 2026 08:11
@burgholzer
burgholzer force-pushed the mlir/builder-call-support branch from db2ac3b to 0c727ef Compare August 28, 2026 12:30
@burgholzer burgholzer added the feature New feature or request label Aug 28, 2026
@burgholzer burgholzer added c++ Anything related to C++ code MLIR Anything related to MLIR labels Aug 28, 2026
Build additional functions, track linear values across supported calls, and reject callees whose correspondence cannot be derived.

Assisted-by: Claude Opus 5 <noreply@anthropic.com>

Assisted-by: Codex
@burgholzer
burgholzer force-pushed the mlir/builder-call-support branch from 0c727ef to 2261fde Compare August 30, 2026 14:21
@burgholzer burgholzer added enhancement Improvement of existing feature and removed feature New feature or request labels Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Anything related to C++ code enhancement Improvement of existing feature MLIR Anything related to MLIR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants