Skip to content

Conversation

@bongjunj
Copy link
Contributor

@bongjunj bongjunj commented Dec 31, 2025

resolves #11971

Run the following command to check:

RUST_LOG=cranelift_codegen::opts::generated_code=trace cargo run -p cranelift-tools --bin clif-util -- compile --target x86_64-unknown-linux-gnu --set opt_level=speed <input.clif>

Should print logs such as:

[2025-12-31T06:48:33Z DEBUG cranelift_codegen::opts::generated_code] ISLE simplify src/opts/remat.isle line 23
[2025-12-31T06:48:33Z DEBUG cranelift_codegen::opts::generated_code] ISLE bnot <OUT_DIR>/clif_opt.isle line 1322
[2025-12-31T06:48:33Z DEBUG cranelift_codegen::opts::generated_code] ISLE bnot <OUT_DIR>/clif_opt.isle line 1322
[2025-12-31T06:48:33Z DEBUG cranelift_codegen::opts::generated_code] ISLE simplify src/opts/remat.isle line 17
[2025-12-31T06:48:33Z DEBUG cranelift_codegen::opts::generated_code] ISLE bor <OUT_DIR>/clif_opt.isle line 1304
[2025-12-31T06:48:33Z DEBUG cranelift_codegen::opts::generated_code] ISLE simplify src/opts/bitops.isle line 48
[2025-12-31T06:48:33Z DEBUG cranelift_codegen::opts::generated_code] ISLE simplify src/opts/remat.isle line 23
[2025-12-31T06:48:33Z DEBUG cranelift_codegen::opts::generated_code] ISLE bnot <OUT_DIR>/clif_opt.isle line 1322

@bongjunj bongjunj requested a review from a team as a code owner December 31, 2025 06:53
@bongjunj bongjunj requested review from cfallin and removed request for a team December 31, 2025 06:53
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language labels Dec 31, 2025
@github-actions
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen

Details This issue or pull request has been labeled: "cranelift", "isle"

Thus the following users have been cc'd because of the following labels:

  • cfallin: isle
  • fitzgen: isle

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

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

Thanks! Happy to merge with the one question below answered/addressed. This will definitely be helpful tracing rule applications!

let pp = pos.pretty_print_line(&self.files);
writeln!(
ctx.out,
"{}#[cfg(feature = \"trace-log\")] log::debug!(\"ISLE {{}} {{}}\", \"{}\", \"{}\");",
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need the #[cfg(feature = "trace-log")] here, since we are already conditionalizing this bit of codegen on the trace-log feature via the emit_logging option, right?

Copy link
Contributor Author

@bongjunj bongjunj Jan 4, 2026

Choose a reason for hiding this comment

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

No, the feature guard isn't necessary as you pointed out, and the test below demonstrates you can safely remove the guard.

> RUST_LOG=cranelift_codegen::opts::generated_code=trace cargo run -p cranelift-tools --bin clif-util -- co
mpile --target x86_64-unknown-linux-gnu --set opt_level=speed ../../keccak-no-opts.clif 2>&1 | head -n10
...
[2026-01-04T04:52:21Z DEBUG cranelift_codegen::opts::generated_code] ISLE simplify src/opts/remat.isle line 25
[2026-01-04T04:52:21Z DEBUG cranelift_codegen::opts::generated_code] ISLE simplify src/opts/remat.isle line 5
[2026-01-04T04:52:21Z DEBUG cranelift_codegen::opts::generated_code] ISLE simplify src/opts/remat.isle line 25
[2026-01-04T04:52:21Z DEBUG cranelift_codegen::opts::generated_code] ISLE simplify src/opts/remat.isle line 5
[2026-01-04T04:52:21Z DEBUG cranelift_codegen::opts::generated_code] ISLE simplify src/opts/remat.isle line 25
[2026-01-04T04:52:21Z DEBUG cranelift_codegen::opts::generated_code] ISLE simplify src/opts/remat.isle line 5
[2026-01-04T04:52:21Z DEBUG cranelift_codegen::opts::generated_code] ISLE simplify src/opts/remat.isle line 25
[2026-01-04T04:52:21Z DEBUG cranelift_codegen::opts::generated_code] ISLE simplify src/opts/remat.isle line 5

> cargo run -p cranelift-tools --bin clif-util -- compile --target x86_64-unknown-linux-gnu --set opt_level
=speed ../../data/clif/keccak-no-opts.clif 2>&1 | head -n10

[No output]

I didn't catch this. Thanks!

@cfallin cfallin added this pull request to the merge queue Jan 6, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 6, 2026
@cfallin
Copy link
Member

cfallin commented Jan 6, 2026

@bongjunj it looks like this fails on Windows (see this CI job) because the paths have backslashes, and when embedding those into strings, they become (ill-formed) escapes. Could you address by either replacing \ with / or by properly escaping somehow?

@bongjunj
Copy link
Contributor Author

bongjunj commented Jan 7, 2026

I have changed the string embedding from Display trait to Debug trait, as Debug trait can automatically place escapes and quotes.

@cfallin cfallin added this pull request to the merge queue Jan 7, 2026
Merged via the queue into bytecodealliance:main with commit ef8a1a7 Jan 7, 2026
45 checks passed
@bongjunj bongjunj deleted the log-fired-isle-rules branch January 8, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ISLE: debugging feature to emit logging in the generated code

2 participants