aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr>2021-08-11 11:27:31 +0200
committerJustus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr>2021-08-11 11:27:31 +0200
commit9e076df6b14e019b569e3a1c3c2e90ef797fe9d2 (patch)
tree13196e07aaeba91af78b5552e8c792b6bd2a28ce
parent103f6065c6240e03495224612c8d8538d6fce42f (diff)
downloadcompcert-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.ml20
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