diff options
-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 |