15
15
open ! Int_replace_polymorphic_compare
16
16
module L = Linear
17
17
18
- let debug =
19
- match Sys. getenv " DEBUG_RANGES" with
20
- | exception Not_found -> false
21
- | _ -> true
22
-
23
18
module Make (S : Compute_ranges_intf.S_functor ) = struct
24
19
module Subrange_state = S. Subrange_state
25
20
module Subrange_info = S. Subrange_info
@@ -301,12 +296,12 @@ module Make (S : Compute_ranges_intf.S_functor) = struct
301
296
~(prev_insn : L.instruction option ) ~known_available_after_prev_insn =
302
297
let available_before = S. available_before insn in
303
298
let available_across = S. available_across insn in
304
- if debug
299
+ if ! Flambda_backend_flags. dranges
305
300
then
306
301
Format. eprintf " canonicalised available_before:@ %a\n "
307
302
(Misc.Stdlib.Option. print KS. print)
308
303
available_before;
309
- if debug
304
+ if ! Flambda_backend_flags. dranges
310
305
then
311
306
Format. eprintf " canonicalised available_across:@ %a\n "
312
307
(Misc.Stdlib.Option. print KS. print)
@@ -324,7 +319,7 @@ module Make (S : Compute_ranges_intf.S_functor) = struct
324
319
~fun_num_stack_slots ~(first_insn : L.instruction ) ~(insn : L.instruction )
325
320
~(prev_insn : L.instruction option ) ~currently_open_subranges
326
321
~subrange_state =
327
- if debug
322
+ if ! Flambda_backend_flags. dranges
328
323
then Format. eprintf " process_instruction:@ %a\n " Printlinear. instr insn;
329
324
let used_label = ref None in
330
325
let get_label () =
@@ -354,12 +349,13 @@ module Make (S : Compute_ranges_intf.S_functor) = struct
354
349
then Misc. fatal_errorf " Key %a already has an open range" S.Key. print key;
355
350
(* If the range is later discarded, the inserted label may actually be
356
351
useless, but this doesn't matter. It does not generate any code. *)
357
- if debug then Format. eprintf " opening subrange for %a\n %!" S.Key. print key;
352
+ if ! Flambda_backend_flags. dranges
353
+ then Format. eprintf " opening subrange for %a\n %!" S.Key. print key;
358
354
let label, label_insn = get_label () in
359
355
KM. add key (label, start_pos_offset, label_insn) currently_open_subranges
360
356
in
361
357
let close_subrange key ~end_pos_offset ~currently_open_subranges =
362
- if debug
358
+ if ! Flambda_backend_flags. dranges
363
359
then Format. eprintf " closing subrange for key %a\n " S.Key. print key;
364
360
match KM. find key currently_open_subranges with
365
361
| exception Not_found ->
@@ -412,12 +408,14 @@ module Make (S : Compute_ranges_intf.S_functor) = struct
412
408
in
413
409
(* Apply actions *)
414
410
let no_actions = List. compare_length_with actions 0 = 0 in
415
- if debug && no_actions then Format. eprintf " no actions to apply\n %!" ;
416
- if debug && not no_actions then Format. eprintf " applying actions:\n %!" ;
411
+ if ! Flambda_backend_flags. dranges && no_actions
412
+ then Format. eprintf " no actions to apply\n %!" ;
413
+ if ! Flambda_backend_flags. dranges && not no_actions
414
+ then Format. eprintf " applying actions:\n %!" ;
417
415
let currently_open_subranges =
418
416
List. fold_left
419
417
(fun currently_open_subranges (key , (action : action )) ->
420
- if debug
418
+ if ! Flambda_backend_flags. dranges
421
419
then
422
420
Format. eprintf " --> action for key %a: %a\n " S.Key. print key
423
421
print_action action;
@@ -437,13 +435,14 @@ module Make (S : Compute_ranges_intf.S_functor) = struct
437
435
close_subrange key ~end_pos_offset: 1 ~currently_open_subranges )
438
436
currently_open_subranges actions
439
437
in
440
- if debug && not no_actions
438
+ if ! Flambda_backend_flags. dranges && not no_actions
441
439
then Format. eprintf " finished applying actions.\n %!" ;
442
440
(* Close all subranges if at last instruction *)
443
441
let currently_open_subranges =
444
442
match insn.desc with
445
443
| Lend ->
446
- if debug then Format. eprintf " closing subranges for last insn\n %!" ;
444
+ if ! Flambda_backend_flags. dranges
445
+ then Format. eprintf " closing subranges for last insn\n %!" ;
447
446
let currently_open_subranges =
448
447
KM. fold
449
448
(fun key _ currently_open_subranges ->
@@ -521,7 +520,8 @@ module Make (S : Compute_ranges_intf.S_functor) = struct
521
520
let empty = { ranges = S.Index.Tbl. create 1 }
522
521
523
522
let create (fundecl : L.fundecl ) =
524
- if debug then Format. eprintf " Compute_ranges for %s\n " fundecl.fun_name;
523
+ if ! Flambda_backend_flags. dranges
524
+ then Format. eprintf " Compute_ranges for %s\n " fundecl.fun_name;
525
525
let t = { ranges = S.Index.Tbl. create 42 } in
526
526
let first_insn =
527
527
process_instructions t fundecl
0 commit comments