diff --git a/crates/celox/src/backend/native/backend.rs b/crates/celox/src/backend/native/backend.rs index 7b8be141152..c9c6ca66fd4 100644 --- a/crates/celox/src/backend/native/backend.rs +++ b/crates/celox/src/backend/native/backend.rs @@ -1799,6 +1799,7 @@ fn format_native_codegen_trace( comb: &CompiledNativeFunction, ff_codes: &HashMap, tasks: &[NativeCompileTask<'_>], + processes: &[CompiledNativeFunction], ) -> NativeCodegenTrace { let mut optimized_sir = String::from("=== Optimized SIR used by native emission ===\n"); let mut mir = String::from("=== MIR used by native emission ===\n"); @@ -1845,6 +1846,20 @@ fn format_native_codegen_trace( .expect("explicit native trace must capture every FF function"), ); } + for (index, process) in processes.iter().enumerate() { + append_native_function_trace( + &mut optimized_sir, + &mut mir, + &mut reactive_graph, + &mut state_layout, + &format!("process[{index}]"), + &[], + process + .trace + .as_ref() + .expect("explicit native trace must capture every process"), + ); + } NativeCodegenTrace { optimized_sir, mir, @@ -2712,7 +2727,7 @@ fn compile_program_with_outlining_threshold( NativeMergeKind::Complete, None, &process_options, - false, + capture_trace, &options.optimize_options.diagnostics, cancel, ) @@ -2743,8 +2758,9 @@ fn compile_program_with_outlining_threshold( } } } - let codegen_trace = capture_trace - .then(|| format_native_codegen_trace(&comb_jit, &compiled_ff_codes, &compile_tasks)); + let codegen_trace = capture_trace.then(|| { + format_native_codegen_trace(&comb_jit, &compiled_ff_codes, &compile_tasks, &process_jits) + }); let semantic_memory_size = layout .merged_total_size .checked_add(layout.triggered_bits_total_size) diff --git a/crates/celox/tests/native_mir.rs b/crates/celox/tests/native_mir.rs index be036c33dab..bd5767f12c2 100644 --- a/crates/celox/tests/native_mir.rs +++ b/crates/celox/tests/native_mir.rs @@ -275,3 +275,35 @@ fn many_clocks_compile_the_comb_program_once() { assert_eq!(functions(2), (1, 2)); assert_eq!(functions(12), (1, 0)); } + +#[test] +fn trace_contains_native_testbench_processes() { + let code = r#" + #[test(test_top)] + module Top { + var q: logic<8>; + initial { + q = 1; + $assert(q == 1); + } + } + "#; + let result = SimulatorBuilder::new(code, "Top") + .trace_mir() + .build_with_trace(); + result.res.expect("native testbench build should succeed"); + assert!( + result + .trace + .native_optimized_sir + .unwrap() + .contains("=== Native function process[0] ===") + ); + assert!( + result + .trace + .mir + .unwrap() + .contains("=== Native function process[0] ===") + ); +}