aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr>2021-08-21 21:38:04 +0200
committerJustus Fasse <justus.fasse@etu.univ-grenoble-alpes.fr>2021-08-21 21:38:04 +0200
commit0b17b5c0a8474e0647283abf66c3e51fb9cfcf60 (patch)
tree38d273ac252fd8d2218be72538be58003f7edf68
parentd89eb8be31e557459a3cb65b1b8485c47468da87 (diff)
downloadcompcert-kvx-0b17b5c0a8474e0647283abf66c3e51fb9cfcf60.tar.gz
compcert-kvx-0b17b5c0a8474e0647283abf66c3e51fb9cfcf60.zip
Hopefully a proper fix to code motion below side exits + NO register renaming
-rw-r--r--scheduling/MyRTLpathScheduleraux.ml23
1 files changed, 23 insertions, 0 deletions
diff --git a/scheduling/MyRTLpathScheduleraux.ml b/scheduling/MyRTLpathScheduleraux.ml
index 2cf58d2e..7afaeaa9 100644
--- a/scheduling/MyRTLpathScheduleraux.ml
+++ b/scheduling/MyRTLpathScheduleraux.ml
@@ -1525,6 +1525,29 @@ let scheduler f =
(List.init (Array.length sb.instructions) (fun i -> i))
PTree.empty
in
+ let (sb, code, pm, next_free_pc, live_renames) =
+ if !Clflags.option_fpoormansssa then
+ (* Final restoration code was already inserted. *)
+ (sb, code, pm, next_free_pc, live_renames)
+ else
+ (* Ther combination of code motion below side exits WITHOUT register renaming may
+ * cause some restoration code to be necessary. Otherwise it is not safe to
+ * duplicate instructions.
+ * The final restoration code is special since it may insert below. *)
+ 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
+ (sb, code, pm, next_free_pc, live_renames)
+ in
let (to_insert_restoration, to_rename, next_free_reg) = restoration_instructions' sb code live_renames ~next_free_reg in
let side_exit_pcs = side_exit_pcs sb code in
let code = ListLabels.fold_left side_exit_pcs