Skip to content
Snippets Groups Projects
Commit 67a679f2 authored by David Bühler's avatar David Bühler
Browse files

[Eva] Auto loop unroll: renames is_safe into is_constant and fixes its comment.

parent dc605d01
No related branches found
No related tags found
No related merge requests found
...@@ -192,17 +192,16 @@ let find_lonely_candidate loop_effect expr = ...@@ -192,17 +192,16 @@ let find_lonely_candidate loop_effect expr =
in in
aux None lvalues aux None lvalues
(* Returns true if the instruction assigns [lval]. *) (* Returns true if the instruction does not modify [lval]. *)
let is_safe_instruction lval = function let is_safe_instruction lval = function
| Set (lv, _, _) | Set (lv, _, _)
| Call (Some lv, _, _, _) -> not (Cil_datatype.LvalStructEq.equal lval lv) | Call (Some lv, _, _, _) -> not (Cil_datatype.LvalStructEq.equal lval lv)
| Call (None, _, _, _) | Local_init _ | Skip _ | Code_annot _ -> true | Call (None, _, _, _) | Local_init _ | Skip _ | Code_annot _ -> true
| Asm _ -> false | Asm _ -> false
(* Returns true if the statement may assign [lval] during an iteration of the (* Returns true if the statement [stmt] of function [kf] does not modify [lval].
loop [loop]. [lval] is a candidate for the automatic loop unroll heuristic, [lval] is a candidate for the automatic loop unrolling of [loop] [loop]. *)
and thus is modified within the loop. *) let is_constant kf ~loop lval stmt =
let is_safe lval kf ~loop stmt =
let rec is_safe_stmt ~goto stmt = let rec is_safe_stmt ~goto stmt =
match stmt.skind with match stmt.skind with
| Instr instr -> is_safe_instruction lval instr | Instr instr -> is_safe_instruction lval instr
...@@ -409,7 +408,7 @@ module Make (Abstract: Abstractions.Eva) = struct ...@@ -409,7 +408,7 @@ module Make (Abstract: Abstractions.Eva) = struct
List.fold_left (fun acc (s, _, _, _, _) -> delta_stmt acc s) acc list List.fold_left (fun acc (s, _, _, _, _) -> delta_stmt acc s) acc list
| _ -> | _ ->
(* For other statements, we only check that they do not modify [lval]. *) (* For other statements, we only check that they do not modify [lval]. *)
if is_safe lval kf ~loop stmt then acc else raise NoIncrement if is_constant kf ~loop lval stmt then acc else raise NoIncrement
and delta_block acc block = and delta_block acc block =
List.fold_left delta_stmt acc block.bstmts List.fold_left delta_stmt acc block.bstmts
in in
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment