@@ -51,7 +51,14 @@ pub fn settle_comb(
5151 // Snapshot inputs so we can restore them for the Cranelift run.
5252 let ff_snap_in: Vec < u8 > = ir. ff_values . to_vec ( ) ;
5353 let comb_snap_in: Vec < u8 > = ir. comb_values . to_vec ( ) ;
54- let count_snap_in: u64 = ir. write_log_buffer . count ( ) as u64 ;
54+ // Snapshot the write-log counts too: a comb settle that lands is_ff writes
55+ // (the is_ff refinement, e.g. function output args) pushes WriteLogEntries.
56+ // Without rewinding before the Cranelift reference run, its pushes accumulate
57+ // on top of the AOT run's (count_jit == count_aot + jit_pushes always
58+ // diverges) — a phantom, since both push identical offsets.
59+ let narrow_snap = ir. write_log_buffer . narrow_count ( ) ;
60+ let wide_snap = ir. write_log_buffer . wide_count ( ) ;
61+ let buf_mut = ( & * ir. write_log_buffer ) as * const _ as * mut crate :: ir:: write_log:: WriteLogBuffer ;
5562
5663 for _ in 0 ..passes {
5764 match whole. try_dispatch ( ff_ptr, comb_ptr, log_ptr) {
@@ -73,8 +80,11 @@ pub fn settle_comb(
7380 std:: ptr:: copy_nonoverlapping ( ff_snap_in. as_ptr ( ) , ff_dst, ff_snap_in. len ( ) ) ;
7481 let comb_dst = ir. comb_values . as_ptr ( ) as * mut u8 ;
7582 std:: ptr:: copy_nonoverlapping ( comb_snap_in. as_ptr ( ) , comb_dst, comb_snap_in. len ( ) ) ;
83+ // Rewind the write-log to the pre-AOT counts so the Cranelift run's
84+ // entries replace (not append to) the AOT run's.
85+ ( * buf_mut) . narrow_count = narrow_snap;
86+ ( * buf_mut) . wide_count = wide_snap;
7687 }
77- let _ = count_snap_in;
7888
7989 ir. run_chunked_settle ( mask_cache, profile) ;
8090
0 commit comments