Skip to content

Commit ec4317f

Browse files
committed
Compiler: add debug variable liveness stats
1 parent 39859c6 commit ec4317f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compiler/lib/deadcode.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,4 +474,13 @@ let f ({ blocks; _ } as p : Code.program) =
474474
~updates:
475475
(st.deleted_instrs + st.deleted_blocks + st.deleted_params + st.block_shortcut);
476476
let p = remove_unused_blocks p in
477+
if stats ()
478+
then (
479+
let live = ref 0 in
480+
Array.iter st.live ~f:(function
481+
| 0 -> ()
482+
| _ -> incr live);
483+
let total = Var.count () in
484+
let ratio = float !live /. float total *. 100. in
485+
Format.eprintf "Stats - live variables: %d/%d = %.1f%%@." !live total ratio);
477486
p, st.live

0 commit comments

Comments
 (0)