Skip to content

Clean up IR diagnostics - #8535

Merged
cristianoc merged 2 commits into
masterfrom
debug-ir-cleanup
Aug 9, 2026
Merged

Clean up IR diagnostics#8535
cristianoc merged 2 commits into
masterfrom
debug-ir-cleanup

Conversation

@cristianoc

Copy link
Copy Markdown
Collaborator

Summary

  • rename internal -bs-diagnose to -debug-ir
  • replace module-global dump counters with a per-compilation Ir_diagnostics context
  • write deterministic artifacts under <output-prefix>.debug-ir/
  • remove stale recognized artifacts before each run
  • remove Js_pass_debug and the no-longer-needed CPPO pass for lam_util
  • add an integration test covering artifacts, numbering, stale cleanup, and rescript clean

Why

The old counters lived for the entire compiler process, so names depended on earlier compilations and made reentrant/multi-file use order-dependent. Artifacts were scattered next to source inputs and accumulated stale files. A compiler-owned directory and per-compilation state make the debug facility recognizable, deterministic, and easy to clean.

-debug-ir remains an umbrella debug mode and implies Lambda invariant checking, while -check-lam stays independently usable.

Validation

  • make test
  • focused debug_ir build integration test
  • native and browser compiler builds
  • unchanged optimized browser bundle size
  • make checkformat

Stack

This is PR 2 of 2 and depends on #8534. Its base should be changed to master after #8534 merges.

@cristianoc
cristianoc marked this pull request as ready for review August 9, 2026 09:07
@cristianoc
cristianoc requested a review from cknitt August 9, 2026 09:08
@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.61039% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.70%. Comparing base (c478363) to head (5039bdb).

Files with missing lines Patch % Lines
compiler/core/lam_util.ml 87.50% 6 Missing ⚠️
compiler/core/ir_diagnostics.ml 92.59% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8535      +/-   ##
==========================================
+ Coverage   74.59%   74.70%   +0.10%     
==========================================
  Files         458      460       +2     
  Lines       62303    62389      +86     
==========================================
+ Hits        46476    46608     +132     
+ Misses      15827    15781      -46     
Files with missing lines Coverage Δ
compiler/bsc/rescript_compiler_main.ml 71.63% <100.00%> (ø)
compiler/common/ext_log.ml 66.66% <100.00%> (+66.66%) ⬆️
compiler/common/js_config.ml 66.66% <ø> (ø)
compiler/core/ir_diagnostics.ml 92.59% <92.59%> (ø)
compiler/core/lam_util.ml 89.83% <87.50%> (ø)

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Aug 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8535

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8535

@rescript/darwin-x64

npm i https://pkg.pr.new/@rescript/darwin-x64@8535

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8535

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8535

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8535

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8535

commit: 5039bdb

@cknitt

cknitt commented Aug 9, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 9f43537a70

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


let is_artifact filename =
match Ext_filename.get_extension_maybe filename with
| ".lam" | ".lambda" | ".jsx" -> true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Slightly confusing that some of these files have the extension .jsx, which does not mean React JSX here.

Maybe we could change that extension in a separate PR?

Base automatically changed from lam-check-command-line to master August 9, 2026 11:50
Replace the ambiguous internal -bs-diagnose option with -debug-ir while preserving its role as an umbrella mode that also enables Lam invariant checks.

Keep diagnostic state per compilation so reentrant and multi-file compiler processes produce deterministic artifacts. Write Lam and JS snapshots into one <output-prefix>.debug-ir directory, use a unified chronological counter, and remove recognized stale artifacts before each run.

Centralize dumping in Ir_diagnostics instead of keeping module-global counters in Lam_util and Js_pass_debug. Remove Js_pass_debug entirely and rename lam_util.cppo.ml now that it no longer contains CPPO directives.

Add a build integration test that verifies Lam, grouped-Lam, and JS artifacts, consecutive numbering, stale-artifact cleanup, and removal by rescript clean.

Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

@cristianoc
cristianoc merged commit 1d80743 into master Aug 9, 2026
29 checks passed
@cristianoc
cristianoc deleted the debug-ir-cleanup branch August 9, 2026 12:18
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.

2 participants