feat(hugr-llvm)!: Add support for emitting debug locations#3026
feat(hugr-llvm)!: Add support for emitting debug locations#3026
Conversation
Codecov Report❌ Patch coverage is 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
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:
|
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>
16cfc08 to
3376256
Compare
|
This PR contains breaking changes to the public Rust API. cargo-semver-checks summary |
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>
There was a problem hiding this comment.
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
!dbgattachments 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-coreand enable printing node-attached debug metadata viahugr 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.
…_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>
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 HUGRsmutwhich 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 inlldb.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 usinghugr mermaid -D.In addition, this and the companion PR in tket2 add the
notailLLVM 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_moduletakes two new args:emit_debug: boolandptr_size: u32. In addition,hugr_core::views::render::NodeLabelhas a new variantMetadataKeywhich combines a numeric label and JSON metadata key.Closes #2978