diff options
author | Cyril SIX <cyril.six@kalray.eu> | 2020-07-09 10:51:41 +0200 |
---|---|---|
committer | Cyril SIX <cyril.six@kalray.eu> | 2020-07-09 10:51:41 +0200 |
commit | 14886020bda9c5461d488ff316b95864f1e1789c (patch) | |
tree | 619311a26d3683f9f8ee2411e57cfd2dd58ab977 /kvx | |
parent | 26525684b6347ce71aeb5494415d99409a1211c5 (diff) | |
download | compcert-kvx-14886020bda9c5461d488ff316b95864f1e1789c.tar.gz compcert-kvx-14886020bda9c5461d488ff316b95864f1e1789c.zip |
Added check on last instruction
Diffstat (limited to 'kvx')
-rw-r--r-- | kvx/lib/RTLpathScheduleraux.ml | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/kvx/lib/RTLpathScheduleraux.ml b/kvx/lib/RTLpathScheduleraux.ml index 5e9111d2..11539994 100644 --- a/kvx/lib/RTLpathScheduleraux.ml +++ b/kvx/lib/RTLpathScheduleraux.ml @@ -194,13 +194,31 @@ let change_predicted_successor i s = match i with | None -> failwith "Predicted a successor for an Icond with p=None - unpredicted CB should not be moved in the middle of the superblock" ) +(** + * Perform basic checks on the new order : + * - must have the same length as the old order + * - non basic instructions (call, tailcall, return, jumptable, non predicted CB) must not move + *) +let check_order code old_order new_order = begin + assert ((Array.length old_order) == (Array.length new_order)); + let length = Array.length new_order in + if length > 0 then + let last_inst = Array.get old_order (length - 1) in + let instr = get_some @@ PTree.get last_inst code in + match predicted_successor instr with + | None -> + if (last_inst != Array.get new_order (length - 1)) then + failwith "The last instruction of the superblock is not basic, but was moved" + | _ -> () +end + let apply_schedule code sb new_order = let tc = ref code in let old_order = sb.instructions in let last_node = Array.get old_order (Array.length old_order - 1) in let last_successors = successors_inst @@ get_some @@ PTree.get last_node code in begin - assert ((Array.length old_order) == (Array.length new_order)); + check_order code old_order new_order; Array.iteri (fun i n' -> let inst' = get_some @@ PTree.get n' code in let new_inst = |