Skip to content

Commit 14f0b83

Browse files
committed
Let --zjit-dump-hir dump the input HIR to codegen (Shopify/zjit#96)
1 parent ddef6a7 commit 14f0b83

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

zjit/src/hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
17081708

17091709
fun.infer_types();
17101710

1711-
match get_option!(dump_hir) {
1711+
match get_option!(dump_hir_init) {
17121712
Some(DumpHIR::WithoutSnapshot) => println!("HIR:\n{}", FunctionPrinter::without_snapshot(&fun)),
17131713
Some(DumpHIR::All) => println!("HIR:\n{}", FunctionPrinter::with_snapshot(&fun)),
17141714
Some(DumpHIR::Debug) => println!("HIR:\n{:#?}", &fun),

zjit/src/options.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ pub struct Options {
1212
/// Enable debug logging
1313
pub debug: bool,
1414

15-
/// Dump High-level IR generated from ISEQ.
16-
pub dump_hir: Option<DumpHIR>,
15+
/// Dump initial High-level IR before optimization
16+
pub dump_hir_init: Option<DumpHIR>,
1717

1818
/// Dump High-level IR after optimization, right before codegen.
1919
pub dump_hir_opt: Option<DumpHIR>,
@@ -58,7 +58,7 @@ pub extern "C" fn rb_zjit_init_options() -> *const u8 {
5858
pub fn init_options() -> Options {
5959
Options {
6060
debug: false,
61-
dump_hir: None,
61+
dump_hir_init: None,
6262
dump_hir_opt: None,
6363
dump_disasm: false,
6464
}
@@ -97,13 +97,14 @@ fn parse_option(options: &mut Options, str_ptr: *const std::os::raw::c_char) ->
9797

9898
("debug", "") => options.debug = true,
9999

100-
("dump-hir", "") => options.dump_hir = Some(DumpHIR::WithoutSnapshot),
101-
("dump-hir", "all") => options.dump_hir = Some(DumpHIR::All),
102-
("dump-hir", "debug") => options.dump_hir = Some(DumpHIR::Debug),
100+
// --zjit-dump-hir dumps the actual input to the codegen, which is currently the same as --zjit-dump-hir-opt.
101+
("dump-hir" | "dump-hir-opt", "") => options.dump_hir_opt = Some(DumpHIR::WithoutSnapshot),
102+
("dump-hir" | "dump-hir-opt", "all") => options.dump_hir_opt = Some(DumpHIR::All),
103+
("dump-hir" | "dump-hir-opt", "debug") => options.dump_hir_opt = Some(DumpHIR::Debug),
103104

104-
("dump-hir-opt", "") => options.dump_hir_opt = Some(DumpHIR::WithoutSnapshot),
105-
("dump-hir-opt", "all") => options.dump_hir_opt = Some(DumpHIR::All),
106-
("dump-hir-opt", "debug") => options.dump_hir_opt = Some(DumpHIR::Debug),
105+
("dump-hir-init", "") => options.dump_hir_init = Some(DumpHIR::WithoutSnapshot),
106+
("dump-hir-init", "all") => options.dump_hir_init = Some(DumpHIR::All),
107+
("dump-hir-init", "debug") => options.dump_hir_init = Some(DumpHIR::Debug),
107108

108109
("dump-disasm", "") => options.dump_disasm = true,
109110

0 commit comments

Comments
 (0)