Skip to content

♻️ Use LLVM streams throughout native code - #2846

Open
burgholzer wants to merge 3 commits into
codex/dd-llvm-iofrom
codex/llvm-streams-followup
Open

burgholzer wants to merge 3 commits into
codex/dd-llvm-iofrom
codex/llvm-streams-followup

Conversation

@burgholzer

@burgholzer burgholzer commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Description

Stacked on #2840, rebased through f1e45d3c62 onto main dedaa13f5f. Replace the remaining production STL streams with LLVM utilities and migrate test fixtures and the documented native consumer.

  • Parse QDMI result keys and DD text lines through borrowed StringRef views. Construct DD regex patterns once; preserve the grammar, numeric errors, zero-qubit results, and key/value pairing.
  • Format simple errors with llvm::formatv and route worker diagnostics through the existing synchronized logger. These diagnostics now use its standard prefix.
  • Require a matching LLVM SDK for native CMake consumers, including the Runtime component. Remove the optional-SDK branch and the documented SDK-free build assumption. Supply missing header usage requirements on LLVMSupport once, so downstream consumers need no manual include paths. The runtime staging helper supplies the executable search path.
  • Require LLVM I/O utilities in AGENTS.md and the development policy. One include check forbids all STL stream headers, including in tests. Replace custom GoogleTest stream printers with LLVM-formatted scoped traces; use native GoogleTest parameter indices for deterministic CTest discovery. The obsolete caller-cout-state assertions are removed.

No public function signatures change. Owned results remain owned; no stream adapter, parser framework, or exception API is added.

Validation

Contract Local evidence
Parsing and execution 4,103 native tests pass with Clang 23 and ThinLTO. Bell and controlled-phase programs retain their results and LLVM QIR.
Key and slice boundaries Public key regression and non-terminated/NUL-containing DD slice regression pass; deliberately skipping empty keys or using C-string regex matching makes the respective test fail.
Rebase Range-diff contains only the upstream exportToDot rename in the affected fixtures. All rebased commits have valid signatures; 64 Python DD tests also pass.
Fixture file handling Existing Graphviz test detects lost executable permissions; the shared writer preserves them and passes UTF-8 paths to LLVM, fixing the Windows Unicode fixture failure.
Native SDK and documentation Complete executable Sphinx/Doxygen documentation and generated links pass. The native example and four installed C++ target consumers run with a compatible LLVM toolchain. The wheel checker receives the original project path to find the downloaded SDK from its isolated test directory. Rendered documentation inspected in Chrome.
Include policy Repository lint passes; the unified guard rejects a forbidden header in the formerly exempt test.
Test diagnostics A deliberate failure probe retains case and builder names in scoped traces. The include guard rejects both ostream and iosfwd.
C++ style Whole-file C++ lint passes for the changes above #2840.

Ponytail review completed. Isolated parser checks support removing one scratch allocation; no end-to-end speedup, live-memory reduction, or peak-RSS reduction is claimed. Validation is local Linux. The published-head Windows test and Linux wheel failures were diagnosed from both architectures and fixed here; platform reruns remain pending. The published-head C++ coverage gate failed at 69.3%. Direct native runtime error checks now supplement the death tests, but worker startup and exception-cleanup diagnostics remain unexercised; the coverage gate is not claimed resolved.

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.
  • 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.

@burgholzer burgholzer added refactor Anything related to code refactoring DD Anything related to the DD package c++ Anything related to C++ code labels Oct 25, 2026
@burgholzer burgholzer self-assigned this Oct 25, 2026
@burgholzer burgholzer added this to the v4.2.0 - SC26 milestone Oct 25, 2026
@burgholzer
burgholzer added this pull request to stack #2847 October 25, 2026 14:26
@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Replace remaining STL stream I/O and borrow QDMI keys and DD text lines.
Build regex patterns once and preserve parsing, ownership and diagnostics
contracts. Migrate test fixtures without changing executable permissions.

Require the matching LLVM SDK for native CMake consumers, simplify SDK
lookup, and enforce the stream policy through focused include checks.

Signed-off-by: Lukas Burgholzer <burgholzer@me.com>
Assisted-by: GPT-6 via Codex
Propagate LLVM headers through LLVMSupport and let runtime staging own
its loader search path. Simplify the native example and stream policy,
and use formatv for simple owned diagnostics.

Keep the original project path available to isolated wheel tests so they
can locate the downloaded SDK. Encode fixture paths as UTF-8 for LLVM on
Windows. Check native runtime exceptions alongside their fatal C boundary.

Signed-off-by: Lukas Burgholzer <burgholzer@me.com>
Assisted-by: GPT-6 via Codex
Put case and builder names in LLVM-formatted scoped traces instead of
custom ostream operators. Keep CTest identifiers deterministic with
NO_PRETTY_VALUES for affected discovered suites.

Ban all STL stream headers in project code and tests, removing the final
exception from the hook and contributor guidance.

Signed-off-by: Lukas Burgholzer <burgholzer@me.com>
Assisted-by: GPT-6 via Codex
@burgholzer
burgholzer force-pushed the codex/llvm-streams-followup branch from b0d8064 to caf5608 Compare October 25, 2026 15:56
@burgholzer
burgholzer enabled stacked auto-merge (squash) October 25, 2026 16:00

This branch has not been deployed

No deployments
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 DD Anything related to the DD package refactor Anything related to code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant