aboutsummaryrefslogtreecommitdiffstats
path: root/backend/Duplicateaux.ml
diff options
context:
space:
mode:
authorCyril SIX <cyril.six@kalray.eu>2020-03-12 16:08:47 +0100
committerCyril SIX <cyril.six@kalray.eu>2020-03-12 16:08:47 +0100
commit786ada1bd193e3995b948e2bd11d6285654a5c6a (patch)
tree1296fed34baba6d5576a0b60a223df3fabf81617 /backend/Duplicateaux.ml
parentc77d6412f132bf6c09189e5f2d3c8799440f1977 (diff)
downloadcompcert-kvx-786ada1bd193e3995b948e2bd11d6285654a5c6a.tar.gz
compcert-kvx-786ada1bd193e3995b948e2bd11d6285654a5c6a.zip
Correcting a few bugs in trace selection and expansion
Diffstat (limited to 'backend/Duplicateaux.ml')
-rw-r--r--backend/Duplicateaux.ml15
1 files changed, 7 insertions, 8 deletions
diff --git a/backend/Duplicateaux.ml b/backend/Duplicateaux.ml
index cabcf1fd..37647714 100644
--- a/backend/Duplicateaux.ml
+++ b/backend/Duplicateaux.ml
@@ -198,9 +198,8 @@ let do_loop_heuristic code cond ifso ifnot is_loop_header =
let get_directions code entrypoint =
let bfs_order = bfs code entrypoint
and is_loop_header = get_loop_headers code entrypoint
- and directions = ref (PTree.map (fun n i -> false) code) (* false <=> fallthru *)
+ and directions = ref (PTree.map (fun n i -> None) code) (* None <=> no predicted direction *)
in begin
- (* Printf.printf "Loop headers: "; *)
(* ptree_printbool is_loop_header; *)
(* Printf.printf "\n"; *)
List.iter (fun n ->
@@ -217,11 +216,10 @@ let get_directions code entrypoint =
| None -> preferred := do_heur code cond ifso ifnot is_loop_header
| Some _ -> ()
) heuristics;
- (match !preferred with None -> (Printf.printf "\tRANDOM\n"; preferred := Some (Random.bool ())) | Some _ -> ());
- directions := PTree.set n (get_some !preferred) !directions;
+ directions := PTree.set n !preferred !directions;
(match !preferred with | Some false -> Printf.printf "\tFALLTHROUGH\n"
- | Some true -> Printf.printf "\tBRANCH\n"
- | None -> ());
+ | Some true -> Printf.printf "\tBRANCH\n"
+ | None -> Printf.printf "\tUNSURE\n");
Printf.printf "---------------------------------------\n"
end
| _ -> ()
@@ -230,7 +228,7 @@ let get_directions code entrypoint =
end
let update_direction direction = function
-| Icond (cond, lr, n, n', _) -> Icond (cond, lr, n, n', Some direction)
+| Icond (cond, lr, n, n', _) -> Icond (cond, lr, n, n', direction)
| i -> i
let rec update_direction_rec directions = function
@@ -239,6 +237,7 @@ let rec update_direction_rec directions = function
in let direction = get_some @@ PTree.get n directions
in PTree.set n (update_direction direction i) (update_direction_rec directions lm)
+(* Uses branch prediction to write prediction annotations in Icond *)
let update_directions code entrypoint =
let directions = get_directions code entrypoint
in begin
@@ -510,7 +509,7 @@ let rec invert_iconds code = function
let duplicate_aux f =
let entrypoint = f.fn_entrypoint in
- let code = f.fn_code in
+ let code = update_directions (f.fn_code) entrypoint in
let traces = select_traces code entrypoint in
let icond_code = invert_iconds code traces in
let preds = get_predecessors_rtl icond_code in