Skip to content

Commit

Permalink
Avoid recomputing the max instruction id (CFG polling).
Browse files Browse the repository at this point in the history
  • Loading branch information
xclerc committed Dec 24, 2024
1 parent dc6e300 commit 8d6edf9
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions backend/cfg/cfg_polling.ml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ let instr_cfg_with_layout :
bool =
fun cfg_with_layout ~safe_map ~back_edges ->
let cfg = Cfg_with_layout.cfg cfg_with_layout in
let next_instruction_id =
lazy
(let cfg_infos = Regalloc_utils.collect_cfg_infos cfg_with_layout in
ref (succ cfg_infos.max_instruction_id))
in
let next_instruction_id () =
let next_ref = Lazy.force next_instruction_id in
let res = !next_ref in
incr next_ref;
res
in
Cfg_loop_infos.EdgeSet.fold
(fun { Cfg_loop_infos.Edge.src; dst } added_poll ->
let needs_poll =
Expand All @@ -201,13 +212,6 @@ let instr_cfg_with_layout :
if needs_poll
then (
let after = Cfg.get_block_exn cfg src in
let cfg_infos = Regalloc_utils.collect_cfg_infos cfg_with_layout in
let next_instruction_id = ref (succ cfg_infos.max_instruction_id) in
let next_instruction_id () =
let res = !next_instruction_id in
incr next_instruction_id;
res
in
let poll =
{ after.terminator with
Cfg.id = next_instruction_id ();
Expand Down

0 comments on commit 8d6edf9

Please sign in to comment.