Skip to content

feat(hugr-llvm)!: Add support for emitting debug locations#3026

Open
cgh-qtnm wants to merge 23 commits intomainfrom
george/debuginfo
Open

feat(hugr-llvm)!: Add support for emitting debug locations#3026
cgh-qtnm wants to merge 23 commits intomainfrom
george/debuginfo

Conversation

@cgh-qtnm
Copy link
Copy Markdown
Contributor

@cgh-qtnm cgh-qtnm commented Apr 16, 2026

This PR adds support for emitting LLVM IR with debug locations taken from the HUGR debug info implemented in Quantinuum/guppylang#1554.

Beyond a few basic unit tests, test coverage is extended by adding random debug info to all existing tests which use hugr-llvm::test::emit::check_emission. This requires marking a lot of test HUGRs mut which were not previously so. I have also externally verified that the emitted IR compiles to a binary with debug info which supports stepping through Guppy lines in lldb.

The PR also adds a Rust specification of the supported metadata in hugr-core::metadata::debug_info, and adds support for dumping HUGR debug info using hugr mermaid -D.

In addition, this and the companion PR in tket2 add the notail LLVM attribute to all HUGR and QIS function calls.
LLVM seems to drop debug info from the callee when performing TCO, so we add this attribute to ensure it's disabled in places where we want to inspect the call stack. Before this change, the only calls that were eligible for TCO were instances of proper tail recursion, so this is unlikely to effect most existing Guppy code. See the discussion on the tket2 PR for more details.

BREAKING CHANGE: hugr-llvm::emit::EmitHugr::emit_hugr::emit_module takes two new args: emit_debug: bool and ptr_size: u32. In addition, hugr_core::views::render::NodeLabel has a new variant MetadataKey which combines a numeric label and JSON metadata key.

Closes #2978

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 81.06713% with 110 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.36%. Comparing base (59ea9a0) to head (3bd16c6).

Files with missing lines Patch % Lines
hugr-llvm/src/emit/debug_info.rs 85.31% 52 Missing and 11 partials ⚠️
hugr-core/src/hugr/views/render.rs 35.00% 13 Missing ⚠️
hugr-llvm/src/emit/func.rs 76.31% 6 Missing and 3 partials ⚠️
hugr-core/src/metadata/debug_info.rs 73.07% 7 Missing ⚠️
hugr-llvm/src/emit.rs 82.35% 6 Missing ⚠️
hugr-cli/src/mermaid.rs 33.33% 3 Missing and 1 partial ⚠️
hugr-llvm/src/emit/ops.rs 50.00% 0 Missing and 4 partials ⚠️
hugr-core/src/core.rs 0.00% 3 Missing ⚠️
hugr-persistent/src/trait_impls.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3026      +/-   ##
==========================================
+ Coverage   81.31%   81.36%   +0.04%     
==========================================
  Files         240      242       +2     
  Lines       45399    45957     +558     
  Branches    39167    39725     +558     
==========================================
+ Hits        36918    37392     +474     
- Misses       6491     6561      +70     
- Partials     1990     2004      +14     
Flag Coverage Δ
python 88.89% <ø> (ø)
rust 80.18% <81.06%> (+0.06%) ⬆️

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.

cgh-qtnm and others added 16 commits April 17, 2026 09:30
Add two unit tests to the existing test module in
hugr-llvm/src/emit/debug_info.rs that cover compilation of a HUGR
with all three supported debug info record types attached:

- CompileUnitRecord on the module root
- SubprogramRecord on a FuncDefn
- LocationRecord on an ExtensionOp

Tests verify that emit_module succeeds and produces a valid LLVM
module both with and without debug info emission enabled.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Test that compilation fails when an incorrect debug info record type
is attached to a node, covering all three node types:

- Module root with SubprogramRecord instead of CompileUnitRecord
- FuncDefn with LocationRecord instead of SubprogramRecord
- ExtensionOp with SubprogramRecord instead of LocationRecord

All three cases result in a deserialization error since all record
types share the same metadata key.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Refactor the error path tests to start from the fully-annotated HUGR
produced by build_hugr_with_all_debug_info() and only override the
specific metadata entry under test, rather than rebuilding the HUGR
from scratch in each test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@hugrbot
Copy link
Copy Markdown
Collaborator

hugrbot commented Apr 17, 2026

This PR contains breaking changes to the public Rust API.

cargo-semver-checks summary
    Building hugr v0.27.0 (current)
     Built [  39.306s] (current)
   Parsing hugr v0.27.0 (current)
    Parsed [   0.005s] (current)
  Building hugr v0.27.0 (baseline)
     Built [  38.990s] (baseline)
   Parsing hugr v0.27.0 (baseline)
    Parsed [   0.005s] (baseline)
  Checking hugr v0.27.0 -> v0.27.0 (assume minor change)
   Checked [   0.013s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  81.632s] hugr
  Building hugr-cli v0.27.0 (current)
     Built [  31.892s] (current)
   Parsing hugr-cli v0.27.0 (current)
    Parsed [   0.007s] (current)
  Building hugr-cli v0.27.0 (baseline)
     Built [  31.864s] (baseline)
   Parsing hugr-cli v0.27.0 (baseline)
    Parsed [   0.007s] (baseline)
  Checking hugr-cli v0.27.0 -> v0.27.0 (assume minor change)
   Checked [   0.017s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  65.897s] hugr-cli
  Building hugr-core v0.27.0 (current)
     Built [  28.016s] (current)
   Parsing hugr-core v0.27.0 (current)
    Parsed [   0.097s] (current)
  Building hugr-core v0.27.0 (baseline)
     Built [  27.591s] (baseline)
   Parsing hugr-core v0.27.0 (baseline)
    Parsed [   0.090s] (baseline)
  Checking hugr-core v0.27.0 -> v0.27.0 (assume minor change)
   Checked [   0.246s] 196 checks: 195 pass, 1 fail, 0 warn, 56 skip

--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/enum_variant_added.ron

Failed in:
variant NodeLabel:MetadataKey in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-core/src/hugr/views/render.rs:183

   Summary semver requires new major version: 1 major and 0 minor checks failed
  Finished [  57.104s] hugr-core
  Building hugr-llvm v0.27.0 (current)
     Built [  31.970s] (current)
   Parsing hugr-llvm v0.27.0 (current)
    Parsed [   0.014s] (current)
  Building hugr-llvm v0.27.0 (baseline)
     Built [  31.755s] (baseline)
   Parsing hugr-llvm v0.27.0 (baseline)
    Parsed [   0.013s] (baseline)
  Checking hugr-llvm v0.27.0 -> v0.27.0 (assume minor change)
   Checked [   0.046s] 196 checks: 195 pass, 1 fail, 0 warn, 56 skip

--- failure method_parameter_count_changed: pub method parameter count changed ---

Description:
A publicly-visible method now takes a different number of parameters, not counting the receiver (self) parameter.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#fn-change-arity
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/method_parameter_count_changed.ron

Failed in:
hugr_llvm::emit::test::Emission::emit_hugr takes 2 parameters in /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-llvm/src/emit/test.rs:38, but now takes 3 parameters in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-llvm/src/emit/test.rs:42
hugr_llvm::emit::EmitHugr::emit_module takes 1 parameters in /home/runner/work/hugr/hugr/BASELINE_BRANCH/hugr-llvm/src/emit.rs:324, but now takes 3 parameters in /home/runner/work/hugr/hugr/PR_BRANCH/hugr-llvm/src/emit.rs:360

   Summary semver requires new major version: 1 major and 0 minor checks failed
  Finished [  65.269s] hugr-llvm
  Building hugr-model v0.27.0 (current)
     Built [  11.550s] (current)
   Parsing hugr-model v0.27.0 (current)
    Parsed [   0.019s] (current)
  Building hugr-model v0.27.0 (baseline)
     Built [  11.493s] (baseline)
   Parsing hugr-model v0.27.0 (baseline)
    Parsed [   0.018s] (baseline)
  Checking hugr-model v0.27.0 -> v0.27.0 (assume minor change)
   Checked [   0.033s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  23.876s] hugr-model
  Building hugr-persistent v0.6.0 (current)
     Built [  23.751s] (current)
   Parsing hugr-persistent v0.6.0 (current)
    Parsed [   0.009s] (current)
  Building hugr-persistent v0.6.0 (baseline)
     Built [  23.412s] (baseline)
   Parsing hugr-persistent v0.6.0 (baseline)
    Parsed [   0.008s] (baseline)
  Checking hugr-persistent v0.6.0 -> v0.6.0 (assume minor change)
   Checked [   0.014s] 196 checks: 196 pass, 56 skip
   Summary no semver update required
  Finished [  48.542s] hugr-persistent

cgh-qtnm and others added 3 commits April 17, 2026 11:22
Add three tests verifying compilation fails when the JSON stored
under the debug info metadata key does not match the expected schema
for each of the three node types:

- CompileUnitRecord on the Module root
- SubprogramRecord on a FuncDefn
- LocationRecord on an ExtensionOp

Uses set_metadata_any with DEBUGINFO_META_KEY to inject arbitrary
JSON directly, bypassing the typed setter. Adds serde_json as a
dev-dependency to construct the malformed values.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@cgh-qtnm cgh-qtnm marked this pull request as ready for review April 17, 2026 18:31
@cgh-qtnm cgh-qtnm requested a review from a team as a code owner April 17, 2026 18:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds end-to-end support for emitting LLVM IR debug locations derived from HUGR debug metadata, and surfaces/debugs that metadata in tooling and tests.

Changes:

  • Emit LLVM debug locations for relevant ops (e.g., calls) and update IR snapshot expectations to include !dbg attachments and module-level debug metadata.
  • Extend test harnesses to inject deterministic “random” debug info into existing HUGR-based tests to broaden coverage of debug emission.
  • Add a debug-metadata spec/module in hugr-core and enable printing node-attached debug metadata via hugr mermaid -D.

Reviewed changes

Copilot reviewed 226 out of 227 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
hugr-persistent/src/trait_impls.rs Updates persistent HUGR rendering to handle new NodeLabel variants (currently panics for MetadataKey).
hugr-llvm/src/test.rs Injects random debug info into test HUGRs and enables debug emission in Emission::emit_hugr(...) calls.
hugr-llvm/src/extension/logic.rs Marks test HUGRs mut to allow debug-info injection.
hugr-llvm/src/extension/int.rs Marks test HUGRs mut to allow debug-info injection.
hugr-llvm/src/extension/float.rs Marks test HUGRs mut to allow debug-info injection.
hugr-llvm/src/extension/conversions.rs Marks test HUGRs mut to allow debug-info injection.
hugr-llvm/src/extension/collections/static_array.rs Marks test HUGRs mut to allow debug-info injection.
hugr-llvm/src/extension/collections/stack_array.rs Marks test HUGRs mut to allow debug-info injection.
hugr-llvm/src/extension/collections/list.rs Marks test HUGRs mut to allow debug-info injection.
hugr-llvm/src/extension/collections/borrow_array.rs Marks test HUGRs mut to allow debug-info injection.
hugr-llvm/src/extension/collections/array.rs Marks test HUGRs mut to allow debug-info injection.
hugr-llvm/src/emit/ops.rs Sets/unsets debug locations around call emission (direct and indirect).
hugr-llvm/src/emit/ops/cfg.rs Marks test HUGRs mut to allow debug-info injection.
hugr-llvm/Cargo.toml Adds rand for debug-info test helpers; adds serde_json for dev usage.
hugr-core/src/metadata.rs Re-exports the new debug_info metadata module.
hugr-core/src/hugr/views/render.rs Adds NodeLabel::MetadataKey to render node metadata as JSON in Mermaid output.
hugr-core/src/core.rs Adds Node::from_portgraph constructor used by rendering.
hugr-cli/src/mermaid.rs Adds -D/--debug-info to render node debug metadata in Mermaid output.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__prelude__test__prelude_unpack_tuple@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__prelude__test__prelude_print@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__prelude__test__prelude_print@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__prelude__test__prelude_noop@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__prelude__test__prelude_noop@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__prelude__test__prelude_make_tuple@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__prelude__test__prelude_make_error@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__prelude__test__prelude_load_nat@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__prelude__test__prelude_load_nat@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__prelude__test__prelude_const_usize@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__prelude__test__prelude_const_usize@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__prelude__test__prelude_const_external_symbol@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__prelude__test__prelude_const_external_symbol@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__logic__test__xor@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__logic__test__xor@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__logic__test__or@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__logic__test__or@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__logic__test__not@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__logic__test__not@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__logic__test__eq@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__logic__test__eq@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__logic__test__and@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__logic__test__and@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__iwiden_u_2_3@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__iwiden_u_2_3@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__iwiden_u_1_6@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__iwiden_u_1_6@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__iwiden_s_2_3@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__iwiden_s_2_3@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__iwiden_s_1_6@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__iwiden_s_1_6@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__isub@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__isub@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__ilt_s@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__ieq@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__iadd@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__iadd@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__emission@pre-mem2reg@llvm21_ineg_[2].snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__int__test__emission@llvm21_ineg_[2].snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fsub@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fsub@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fround@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fpow@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fneg@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fneg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fne@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fmul@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fmul@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__flt@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fle@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fgt@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fge@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__feq@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fdiv@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fdiv@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fadd@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__fadd@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__const_float@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__float__test__const_float@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__conversions__test__itobool@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__conversions__test__ifrombool@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__conversions__test__convert_u@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__conversions__test__convert_u@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__conversions__test__convert_s@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/snapshots/hugr_llvm__extension__conversions__test__convert_s@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__static_array__test__static_array_op_codegen@llvm21_3.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__static_array__test__static_array_op_codegen@llvm21_2.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__static_array__test__static_array_const_codegen@pre-mem2reg@llvm21_3.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__static_array__test__static_array_const_codegen@pre-mem2reg@llvm21_2.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__static_array__test__static_array_const_codegen@pre-mem2reg@llvm21_1.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__static_array__test__static_array_const_codegen@pre-mem2reg@llvm21_0.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__static_array__test__static_array_const_codegen@llvm21_3.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__static_array__test__static_array_const_codegen@llvm21_2.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__static_array__test__static_array_const_codegen@llvm21_1.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__static_array__test__static_array_const_codegen@llvm21_0.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__list__test__push@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__list__test__length@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__list__test__const@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__list__test__const@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__borrow_array__test__emit_array_value@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__borrow_array__test__emit_array_value@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__array__test__emit_array_value@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/extension/collections/snapshots/hugr_llvm__extension__collections__array__test__emit_array_value@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__tail_loop_simple@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__tail_loop_simple@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__load_function@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__load_function@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__emit_hugr_tag@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__emit_hugr_tag@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__emit_hugr_load_constant@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__emit_hugr_load_constant@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__emit_hugr_dfg@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__emit_hugr_dfg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__emit_hugr_custom_op@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__emit_hugr_custom_op@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__emit_hugr_conditional@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__diverse_module_children@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__diverse_module_children@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__diverse_cfg_children@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/snapshots/hugr_llvm__emit__test__test_fns__diverse_cfg_children@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/ops/snapshots/hugr_llvm__emit__ops__cfg__test__nested@pre-mem2reg@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/ops/snapshots/hugr_llvm__emit__ops__cfg__test__nested@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.
hugr-llvm/src/emit/ops/snapshots/hugr_llvm__emit__ops__cfg__test__diverse_outputs@llvm21.snap Snapshot updated to include debug metadata and !dbg locations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hugr-llvm/src/emit/ops.rs Outdated
Comment thread hugr-llvm/Cargo.toml Outdated
Comment thread hugr-persistent/src/trait_impls.rs Outdated
Comment thread hugr-core/src/hugr/views/render.rs Outdated
cgh-qtnm and others added 4 commits April 17, 2026 13:27
…_with_formatter

Previously, rendering a PersistentHugr with NodeLabel::MetadataKey (e.g.
via `hugr mermaid -D <key>`) would panic with unimplemented!(). Since
apply_all() produces a materialized Hugr that preserves node metadata,
the key can simply be passed through to the extracted Hugr's formatter.

Fixes: #3026 (comment)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extract the inline name-unmangling logic from DebugInfoBuilder::add_di_func
into a standalone free function unmangle_hugr_func_name, and add unit tests
covering both the happy path (well-formed mangled names) and preservation of
names not in the expected form.

Also fixes a pre-existing edge-case bug: the old unwrap_or(0) fallback for
the second-dot index caused single-component names (no dots) to have their
first character stripped, since lpar=0 and rpar=name.len() made the slice
condition true.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

[Feature]: Add debug information metadata specification in Rust

3 participants