Skip to content

feat: Support debug info in qis-compiler#1521

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

feat: Support debug info in qis-compiler#1521
cgh-qtnm wants to merge 11 commits intomainfrom
george/debuginfo

Conversation

@cgh-qtnm
Copy link
Copy Markdown
Contributor

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

This PR adopts the debug info support being implemented for hugr-llvm in Quantinuum/hugr#3026, by adding an emit_debug parameter to the qis-compiler entry points. See the hugr PR for an explanation of the test changes. This PR also updates the sample HUGRs used in test_basic_generation.py to include debug info.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 2.50000% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.73%. Comparing base (680ba72) to head (79599fc).

Files with missing lines Patch % Lines
qis-compiler/rust/lib.rs 0.00% 38 Missing ⚠️
qis-compiler/python/tests/test_basic_generation.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1521      +/-   ##
==========================================
- Coverage   83.82%   83.73%   -0.10%     
==========================================
  Files         187      187              
  Lines       28954    28987      +33     
  Branches    27875    27908      +33     
==========================================
  Hits        24271    24271              
- Misses       3522     3555      +33     
  Partials     1161     1161              
Flag Coverage Δ
python 92.33% <ø> (ø)
qis-compiler 91.66% <50.00%> (ø)
rust 83.39% <0.00%> (-0.10%) ⬇️

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
Copy link
Copy Markdown
Contributor Author

Codecov Report

❌ Patch coverage is 2.56410% with 38 lines in your changes missing coverage. Please review.

I believe these lines are covered by the tests in qis-compiler/python/tests/test_basic_generation.py.

@cgh-qtnm cgh-qtnm marked this pull request as ready for review April 20, 2026 17:31
@cgh-qtnm cgh-qtnm requested a review from a team as a code owner April 20, 2026 17:31
@cgh-qtnm cgh-qtnm requested a review from cqc-alec April 20, 2026 17:31
Comment thread Cargo.toml
# hugr-core = { git = "https://github.com/quantinuum/hugr", "rev" = "de7b9f7581ae02cd80dff7b12794b55635903304" }
# hugr-cli = { git = "https://github.com/quantinuum/hugr", "rev" = "de7b9f7581ae02cd80dff7b12794b55635903304" }
# hugr-llvm = { git = "https://github.com/quantinuum/hugr", "rev" = "de7b9f7581ae02cd80dff7b12794b55635903304" }
hugr = { git = "https://github.com/quantinuum/hugr", branch = "george/debuginfo" }
Copy link
Copy Markdown
Contributor Author

@cgh-qtnm cgh-qtnm Apr 20, 2026

Choose a reason for hiding this comment

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

Need to update to a released version of HUGR and remove these patches before merging.

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

This PR propagates HUGR/LLVM debug info support into the qis-compiler entry points by adding an emit_debug parameter, then updates tests and stored snapshots/resources to reflect the new debug metadata emitted into LLVM IR.

Changes:

  • Expose emit_debug (and target_triple) in the Python bindings/stubs and enable debug info in test_basic_generation.py.
  • Regenerate/update LLVM IR snapshots across tket, tket-qsystem, and qis-compiler to include debug metadata (!dbg, !DICompileUnit, !DIFile, etc.).
  • Update the HUGR generator script/resources to include debug info and bump insta patch versions.

Reviewed changes

Copilot reviewed 162 out of 175 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
Cargo.toml Enables git patch overrides for hugr* crates to pick up debug-info work.
tket/Cargo.toml Bumps insta patch version for snapshot compatibility.
tket/src/llvm/bool.rs Adjusts test HUGR to be mutable (likely required by debug/info emission pipeline).
tket/src/llvm/rotation.rs Makes test HUGR mutable; renames a test function exec_aaddexec_add.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@llvm21_1.snap Updates IR snapshot to include debug metadata.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@llvm21_2.snap Updates IR snapshot to include debug metadata.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@llvm21_3.snap Updates IR snapshot to include debug metadata.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@llvm21_4.snap Updates IR snapshot to include debug metadata.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@llvm21_5.snap Updates IR snapshot to include debug metadata.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@llvm21_6.snap Updates IR snapshot to include debug metadata.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@llvm21_7.snap Updates IR snapshot to include debug metadata.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@pre-mem2reg@llvm21_1.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@pre-mem2reg@llvm21_2.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@pre-mem2reg@llvm21_3.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@pre-mem2reg@llvm21_4.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@pre-mem2reg@llvm21_5.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@pre-mem2reg@llvm21_6.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket/src/llvm/snapshots/tket__llvm__bool__test__emit_all_ops@pre-mem2reg@llvm21_7.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/debug.rs Makes test HUGR mutable for emission.
tket-qsystem/src/llvm/futures.rs Makes test HUGR mutable for emission.
tket-qsystem/src/llvm/prelude.rs Makes test HUGRs mutable for emission.
tket-qsystem/src/llvm/random.rs Makes test HUGR mutable for emission.
tket-qsystem/src/llvm/result.rs Makes test HUGR mutable for emission.
tket-qsystem/src/llvm/utils.rs Makes test HUGR mutable for emission.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__utils__test__emit_utils_codegen@llvm21_1.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__utils__test__emit_utils_codegen@pre-mem2reg@llvm21_1.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@llvm21_1.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@llvm21_2.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@llvm21_3.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@llvm21_4.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@llvm21_12.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@llvm21_13.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@llvm21_15.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@llvm21_16.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@pre-mem2reg@llvm21_1.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@pre-mem2reg@llvm21_2.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@pre-mem2reg@llvm21_3.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@pre-mem2reg@llvm21_4.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@pre-mem2reg@llvm21_12.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@pre-mem2reg@llvm21_13.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@pre-mem2reg@llvm21_15.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__result__test__emit_result_codegen@pre-mem2reg@llvm21_16.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__random__test__emit_random_codegen@llvm21.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__random__test__emit_random_codegen@llvm21_1.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__random__test__emit_random_codegen@llvm21_2.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__random__test__emit_random_codegen@llvm21_3.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__random__test__emit_random_codegen@llvm21_4.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__random__test__emit_random_codegen@llvm21_5.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__random__test__emit_random_codegen@[email protected] Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__random__test__emit_random_codegen@pre-mem2reg@llvm21_1.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__random__test__emit_random_codegen@pre-mem2reg@llvm21_2.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__random__test__emit_random_codegen@pre-mem2reg@llvm21_3.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__random__test__emit_random_codegen@pre-mem2reg@llvm21_4.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__random__test__emit_random_codegen@pre-mem2reg@llvm21_5.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@llvm21_1.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@llvm21_2.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@llvm21_3.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@llvm21_4.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@llvm21_5.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@llvm21_6.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@llvm21_7.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@llvm21_8.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@llvm21_9.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@llvm21_10.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@pre-mem2reg@llvm21_1.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@pre-mem2reg@llvm21_2.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@pre-mem2reg@llvm21_3.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@pre-mem2reg@llvm21_4.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@pre-mem2reg@llvm21_5.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@pre-mem2reg@llvm21_6.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@pre-mem2reg@llvm21_7.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@pre-mem2reg@llvm21_8.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@pre-mem2reg@llvm21_9.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__qsystem__test__emit_qsystem_codegen@pre-mem2reg@llvm21_10.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__prelude__test__panic_emit@llvm21_0.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__prelude__test__panic_emit@pre-mem2reg@llvm21_0.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__prelude__test__exit_emit@llvm21_0.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__prelude__test__exit_emit@pre-mem2reg@llvm21_0.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__futures__test__emit_futures_codegen@llvm21_1.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__futures__test__emit_futures_codegen@llvm21_2.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__futures__test__emit_futures_codegen@llvm21_3.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__futures__test__emit_futures_codegen@llvm21_4.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__futures__test__emit_futures_codegen@llvm21_5.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__futures__test__emit_futures_codegen@llvm21_6.snap Updates IR snapshot to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__futures__test__emit_futures_codegen@pre-mem2reg@llvm21_1.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__futures__test__emit_futures_codegen@pre-mem2reg@llvm21_2.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__futures__test__emit_futures_codegen@pre-mem2reg@llvm21_3.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__futures__test__emit_futures_codegen@pre-mem2reg@llvm21_4.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__futures__test__emit_futures_codegen@pre-mem2reg@llvm21_5.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
tket-qsystem/src/llvm/snapshots/tket_qsystem__llvm__futures__test__emit_futures_codegen@pre-mem2reg@llvm21_6.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
qis-compiler/Cargo.toml Bumps insta patch version for snapshot compatibility.
qis-compiler/rust/gpu.rs Makes test HUGR mutable for emission.
qis-compiler/rust/snapshots/selene_hugr_qis_compiler__gpu__test__gpu_codegen@llvm21_call_ret_float.snap Updates IR snapshot to include debug metadata.
qis-compiler/rust/snapshots/selene_hugr_qis_compiler__gpu__test__gpu_codegen@llvm21_call_ret_int.snap Updates IR snapshot to include debug metadata.
qis-compiler/rust/snapshots/selene_hugr_qis_compiler__gpu__test__gpu_codegen@llvm21_dispose_context.snap Updates IR snapshot to include debug metadata.
qis-compiler/rust/snapshots/selene_hugr_qis_compiler__gpu__test__gpu_codegen@llvm21_lookup_by_id.snap Updates IR snapshot to include debug metadata.
qis-compiler/rust/snapshots/selene_hugr_qis_compiler__gpu__test__gpu_codegen@llvm21_read_result_int.snap Updates IR snapshot to include debug metadata.
qis-compiler/rust/snapshots/selene_hugr_qis_compiler__gpu__test__gpu_codegen@pre-mem2reg@llvm21_dispose_context.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
qis-compiler/rust/snapshots/selene_hugr_qis_compiler__gpu__test__gpu_codegen@pre-mem2reg@llvm21_lookup_by_id.snap Updates IR snapshot (pre-mem2reg) to include debug metadata.
qis-compiler/python/selene_hugr_qis_compiler/selene_hugr_qis_compiler.pyi Updates type stubs for new emit_debug/target_triple parameters.
qis-compiler/python/tests/generate_hugrs.py Enables guppylang debug mode when generating HUGR test resources.
qis-compiler/python/tests/resources/entry_args.hugr Adds/updates a HUGR resource used by Python tests.
qis-compiler/python/tests/test_basic_generation.py Enables emit_debug=True for LLVM snapshot tests.
qis-compiler/python/tests/snapshots/test_basic_generation/test_llvm/x86_64-unknown-linux-gnu-print_current_shot/print_current_shot_x86_64-unknown-linux-gnu Updates Python LLVM snapshot to include debug metadata.
qis-compiler/python/tests/snapshots/test_basic_generation/test_llvm/x86_64-apple-darwin-print_current_shot/print_current_shot_x86_64-apple-darwin Updates Python LLVM snapshot to include debug metadata.
qis-compiler/python/tests/snapshots/test_basic_generation/test_llvm/aarch64-apple-darwin-print_current_shot/print_current_shot_aarch64-apple-darwin Updates Python LLVM snapshot to include debug metadata.
qis-compiler/python/tests/snapshots/test_basic_generation/test_llvm/x86_64-windows-msvc-print_current_shot/print_current_shot_x86_64-windows-msvc Updates Python LLVM snapshot to include debug metadata.

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

Comment thread qis-compiler/python/tests/test_basic_generation.py Outdated
Comment thread Cargo.toml
Comment thread qis-compiler/python/tests/generate_hugrs.py Outdated
Comment thread qis-compiler/python/tests/generate_hugrs.py
Comment on lines +37 to +42
!1 = distinct !DICompileUnit(language: DW_LANG_Python, file: !2, producer: "guppylang (guppylang-internals-v0.32.0)-v0.21.11", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
!2 = !DIFile(filename: "/Users/george.hodgkins/proj/tket2/qis-compiler/python/tests/generate_hugrs.py", directory: "file:///Users/george.hodgkins/proj/clone-anduril")
!3 = !{!"mainlib"}
!4 = distinct !DISubprogram(name: "print_current_shot.<locals>.main", linkageName: "__hugr__.__main__.print_current_shot.<locals>.main.1", scope: null, file: !5, line: 194, type: !6, scopeLine: 195, spFlags: DISPFlagDefinition, unit: !1)
!5 = !DIFile(filename: "/Users/george.hodgkins/proj/tket2/qis-compiler/python/tests/generate_hugrs.py", directory: "")
!6 = !DISubroutineType(types: !7)
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

This snapshot hard-codes an absolute local path (including a username) in the embedded debug metadata (!DIFile). This leaks developer machine details into the repo and is brittle if resources are regenerated elsewhere. Prefer emitting a sanitized/relative filename (or a constant like COMPILER_GENERATED_CODE) when generating the HUGR debug info used by tests.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

@cgh-qtnm cgh-qtnm Apr 20, 2026

Choose a reason for hiding this comment

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

This is a good point, not sure it's avoidable with our current frontend generation though. It doesn't affect the current tests because they just use whatever is present in the HUGR (don't actually resolve the path).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looked into it and clang also produces DIFile entries with absolute paths, so I think we will keep that approach and live with the consequences.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Recommend some anonymisation run on IR text before turning it into a snapshot. Otherwise CI will not be able to reproduce it and the snapshot test is guaranteed to fail, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The snapshot doesn't fail because this string is present in the input HUGR, and the compiler just copies it into the bitcode without interpreting it. But I will sanitize it for tidiness

# "tket",
# ]
# ///
# TODO: point at re-released guppylang(-internals) once available with debug info. right
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Need to fix this before merging, once latest guppylang is rereleased.

%1 = tail call i64 @teardown()
ret i64 %1
tail call void @setup(i64 %0), !dbg !24
tail call void @"__hugr__.__main__.flip_some.<locals>.main.1"(), !dbg !24
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we switch off tail calls for debug builds?

I don't know how we can recover DWARF metadata if we can't reliably walk the call stack. I guess this could be done manually when compiling bitcode to an object file (-fno-optimize-sibling-calls) but it feels like we shouldn't be hinting it anyway.

Copy link
Copy Markdown
Contributor Author

@cgh-qtnm cgh-qtnm Apr 21, 2026

Choose a reason for hiding this comment

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

Looked into this:

  1. tail call by itself actually has no effect unless a) explicitly enabled with -tailcallopt or b) the call is immediately followed by a return (this is the case covered by optimize-sibling-calls). And even if enabled with -tailcallopt, it still has no effect unless the call site (or callee function?) is labeled with a non-default calling convention like fastcc.

  2. Even when compiling a tail call fastcc with llc -tailcallopt, it seems that a stack frame is still generated (or at least the calling convention uses a normal-looking bl-ret pair) on Linux and Darwin aarch64, and on Darwin at least the debugger displays a correct backtrace at a call site that was marked with tail.

TLDR, if the tail call annotations currently don't propagate to codegen, I think we should just disable them in hugr-llvm and QsystemPass unless/until we want them.

@cqc-alec cqc-alec removed their request for review April 27, 2026 12:08
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.

3 participants