diff options
author | Justus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr> | 2021-08-21 21:07:14 +0200 |
---|---|---|
committer | Justus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr> | 2021-08-21 21:07:14 +0200 |
commit | a0119e5987a1cd84f2baa9286f39b1fc6498af23 (patch) | |
tree | 36bdaf4dda4a14852bf56a798e16ea7695cc9ff4 | |
parent | 026cb2e2cb229c3651c2e0a117cd1893a59930e3 (diff) | |
download | compcert-kvx-a0119e5987a1cd84f2baa9286f39b1fc6498af23.tar.gz compcert-kvx-a0119e5987a1cd84f2baa9286f39b1fc6498af23.zip |
Fix error
When code motion past side exits is NOT combined with general register
renaming, the renaming necessary to make it safe to duplicate
instructions may cause final restoration code to be inserted.
Final restoration code is trated specially by its own function.
-rw-r--r-- | scheduling/MyRTLpathScheduleraux.ml | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/scheduling/MyRTLpathScheduleraux.ml b/scheduling/MyRTLpathScheduleraux.ml index 2cf58d2e..7dcb147c 100644 --- a/scheduling/MyRTLpathScheduleraux.ml +++ b/scheduling/MyRTLpathScheduleraux.ml @@ -1428,9 +1428,9 @@ let scheduler f = (sb, to_insert_compensation_pcs, live_renames ) ) in - let (sb_tocompensate_liverenames, code, next_free_reg) = ListLabels.fold_left sb_tocompensatepcs_liverenames - ~init:([], code, next_free_reg) - ~f:(fun (sbs, code, next_free_reg) (sb, to_compensate_pcs, live_renames) -> + let (sb_tocompensate_liverenames, code, pm, next_free_reg, next_free_pc) = ListLabels.fold_left sb_tocompensatepcs_liverenames + ~init:([], code, pm, next_free_reg, next_free_pc) + ~f:(fun (sbs, code, pm, next_free_reg, next_free_pc) (sb, to_compensate_pcs, live_renames) -> if !Clflags.option_fpoormansssa then ( let to_compensate = InsertPositionMap.map (fun pcs -> let insts = List.map (fun pc -> get_some @@ PTree.get pc code) pcs in @@ -1445,7 +1445,7 @@ let scheduler f = to_compensate_pcs code in - ((sb, to_compensate, live_renames)::sbs, code, next_free_reg) + ((sb, to_compensate, live_renames)::sbs, code, pm, next_free_reg, next_free_pc) ) else ( assert (PTree.elements live_renames |> List.for_all (fun (_, l) -> l = [])); let dup_count = InsertPositionMap.fold @@ -1477,6 +1477,18 @@ let scheduler f = in let pi = get_some @@ PTree.get sb.instructions.(0) pm in let (code, live_renames, next_free_reg) = rename_regs ~only_rename:arg_regs sb code ~liveatentry:pi.input_regs ~next_free_reg in + let final_restoration = final_restoration_code sb code live_renames in + let (sb, code, pm, next_free_pc, fwmap) = insert_code sb code pm final_restoration ~next_free_pc in + let live_renames = + PTree.fold + (fun acc pc insts -> + let pc' = apply_map' fwmap pc in + (* Remove final renames, which were just inserted *) + let insts = if Camlcoq.P.eq pc sb.instructions.(Array.length sb.instructions - 1) then [] else insts in + PTree.set pc' insts acc) + live_renames + PTree.empty + in let to_compensate = InsertPositionMap.map (fun pcs -> let insts = List.map (fun pc -> get_some @@ PTree.get pc code) pcs in insts) @@ -1490,7 +1502,7 @@ let scheduler f = to_compensate_pcs code in - ((sb, to_compensate, live_renames)::sbs, code, next_free_reg) )) + ((sb, to_compensate, live_renames)::sbs, code, pm, next_free_reg, next_free_pc) )) in (* Insert the compensation code (downward scheduling) and update the restoration code |