diff options
author | Justus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr> | 2021-08-11 11:27:31 +0200 |
---|---|---|
committer | Justus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr> | 2021-08-11 11:27:31 +0200 |
commit | 9e076df6b14e019b569e3a1c3c2e90ef797fe9d2 (patch) | |
tree | 13196e07aaeba91af78b5552e8c792b6bd2a28ce | |
parent | 103f6065c6240e03495224612c8d8538d6fce42f (diff) | |
download | compcert-kvx-9e076df6b14e019b569e3a1c3c2e90ef797fe9d2.tar.gz compcert-kvx-9e076df6b14e019b569e3a1c3c2e90ef797fe9d2.zip |
Allow restoration instructions at the very end of the path.
This becomes necessary once we allow register renaming for the
originally last instruction of the path.
-rw-r--r-- | scheduling/MyRTLpathScheduleraux.ml | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/scheduling/MyRTLpathScheduleraux.ml b/scheduling/MyRTLpathScheduleraux.ml index 30255424..293faccf 100644 --- a/scheduling/MyRTLpathScheduleraux.ml +++ b/scheduling/MyRTLpathScheduleraux.ml @@ -380,7 +380,18 @@ let local_single_assignment sb code liveatentry ~next_free_reg = debug_flag := old_debug_flag; (code, live_renames, next_free_reg) -let restoration_instructions live_renames = +let restoration_instructions sb code live_renames = + let last_inst_pc = sb.instructions.(Array.length sb.instructions - 1) in + let last_inst = get_some @@ PTree.get last_inst_pc code in + let last_inst_is_basic = match last_inst with + | Icall _ + | Ibuiltin _ + | Ijumptable _ + | Itailcall _ + | Ireturn _ + | Icond _ -> false + | _ -> true + in let to_insert = PTree.fold (fun to_insert side_exit_pc renames -> @@ -388,7 +399,12 @@ let restoration_instructions live_renames = ~f:(fun {old_name; new_name} -> Iop (Op.Omove, [new_name], old_name, Camlcoq.P.one)) in - InsertPositionMap.add (InsertPosition.Above side_exit_pc) insts to_insert) + let pos = if last_inst_is_basic + then InsertPosition.Below side_exit_pc + else InsertPosition.Above side_exit_pc + in + + InsertPositionMap.add pos insts to_insert) live_renames InsertPositionMap.empty in |