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

[Eva] Relaxed heuristic for automatic loop unroll.

parent d5a31905
No related branches found
No related tags found
No related merge requests found
...@@ -1259,6 +1259,8 @@ src/plugins/value/legacy/function_args.ml: CEA_LGPL_OR_PROPRIETARY ...@@ -1259,6 +1259,8 @@ src/plugins/value/legacy/function_args.ml: CEA_LGPL_OR_PROPRIETARY
src/plugins/value/legacy/function_args.mli: CEA_LGPL_OR_PROPRIETARY src/plugins/value/legacy/function_args.mli: CEA_LGPL_OR_PROPRIETARY
src/plugins/value/register.ml: CEA_LGPL_OR_PROPRIETARY src/plugins/value/register.ml: CEA_LGPL_OR_PROPRIETARY
src/plugins/value/register.mli: CEA_LGPL_OR_PROPRIETARY src/plugins/value/register.mli: CEA_LGPL_OR_PROPRIETARY
src/plugins/value/partitioning/auto_loop_unroll.ml: CEA_LGPL_OR_PROPRIETARY
src/plugins/value/partitioning/auto_loop_unroll.mli: CEA_LGPL_OR_PROPRIETARY
src/plugins/value/partitioning/partitioning_parameters.ml: CEA_LGPL_OR_PROPRIETARY src/plugins/value/partitioning/partitioning_parameters.ml: CEA_LGPL_OR_PROPRIETARY
src/plugins/value/partitioning/partitioning_parameters.mli: CEA_LGPL_OR_PROPRIETARY src/plugins/value/partitioning/partitioning_parameters.mli: CEA_LGPL_OR_PROPRIETARY
src/plugins/value/partitioning/per_stmt_slevel.ml: CEA_LGPL_OR_PROPRIETARY src/plugins/value/partitioning/per_stmt_slevel.ml: CEA_LGPL_OR_PROPRIETARY
......
...@@ -38,10 +38,10 @@ ...@@ -38,10 +38,10 @@
The heuristic is syntactic and limited to the current function: it does not The heuristic is syntactic and limited to the current function: it does not
handle assignment through pointers or function calls. handle assignment through pointers or function calls.
Thus, the condition [cond] must only contains direct accesses to variables Thus, the condition [cond] should only contains direct accesses to variables
whose address is never taken (they cannot be modified through pointers). If whose address is never taken (they cannot be modified through pointers). If
the loop contains a function call, the condition [cond] must not contain any the loop contains a function call, the condition [cond] should not contain
global variable (as they may be modified in the function called). global variables (as they may be modified in the function called).
A first analyze of the loop gathers all such variables modified within the A first analyze of the loop gathers all such variables modified within the
loop; all others are constant, and can be evaluated in the loop entry state. loop; all others are constant, and can be evaluated in the loop entry state.
...@@ -113,7 +113,7 @@ end ...@@ -113,7 +113,7 @@ end
(* The status of a lvalue for the automatic loop unroll heuristic. *) (* The status of a lvalue for the automatic loop unroll heuristic. *)
type var_status = type var_status =
| Constant (* The lvalue is constant within the loop. *) | Constant (* The lvalue is probably constant within the loop. *)
| Candidate (* The lvalue is a good candidate for the heuristic: | Candidate (* The lvalue is a good candidate for the heuristic:
integer type, access to a varinfo whose address is not taken, integer type, access to a varinfo whose address is not taken,
modified within the loop but not in another function called modified within the loop but not in another function called
...@@ -134,13 +134,17 @@ let classify loop_effect lval = ...@@ -134,13 +134,17 @@ let classify loop_effect lval =
| AlignOf _ | AlignOfE _ | AddrOf _ | StartOf _ -> true | AlignOf _ | AlignOfE _ | AddrOf _ | StartOf _ -> true
and classify_lval = function and classify_lval = function
| Var varinfo, offset -> | Var varinfo, offset ->
if varinfo.vaddrof if (varinfo.vglob && loop_effect.call)
|| (varinfo.vglob && loop_effect.call)
|| not (is_const_offset offset) || not (is_const_offset offset)
then Unsuitable then Unsuitable
else if Cil_datatype.Varinfo.Set.mem varinfo loop_effect.written_vars else if Cil_datatype.Varinfo.Set.mem varinfo loop_effect.written_vars
then if is_integer lval then Candidate else Unsuitable then
else Constant if is_integer lval && not varinfo.vaddrof then Candidate else Unsuitable
else
(* If the address of the variable is taken, it could be modified within
the loop. We suppose here that this is not the case, but this could
lead to some loop unrolling. *)
Constant
| Mem _, _ -> Unsuitable (* Pointers are not supported by the heuristic. *) | Mem _, _ -> Unsuitable (* Pointers are not supported by the heuristic. *)
and is_const_offset = function and is_const_offset = function
| NoOffset -> true | NoOffset -> true
......
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