forked from ocaml/ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
invariant_params.mli
57 lines (46 loc) · 2.39 KB
/
invariant_params.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Pierre Chambart, OCamlPro *)
(* Mark Shinwell and Leo White, Jane Street Europe *)
(* *)
(* Copyright 2013--2016 OCamlPro SAS *)
(* Copyright 2014--2016 Jane Street Group LLC *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)
[@@@ocaml.warning "+a-4-9-30-40-41-42"]
(* [invariant_params_in_recursion] calculates the set of parameters whose
values are known not to change during the execution of a recursive
function. As such, occurrences of the parameters may always be replaced
by the corresponding values.
For example, [x] would be in [invariant_params] for both of the following
functions:
let rec f x y = (f x y) + (f x (y+1))
let rec f x l = List.iter (f x) l
For invariant parameters it also computes the set of parameters of functions
in the set of closures that are always aliased to it. For example in the set
of closures:
let rec f x y = (f x y) + (f x (y+1)) + g x
and g z = z + 1
The map of aliases is
x -> { x; z }
*)
val invariant_params_in_recursion
: Flambda.function_declarations
-> backend:(module Backend_intf.S)
-> Variable.Set.t Variable.Map.t
val invariant_param_sources
: Flambda.function_declarations
-> backend:(module Backend_intf.S)
-> Variable.Pair.Set.t Variable.Map.t
(* CR-soon mshinwell: think about whether this function should
be in this file. Should it be called "unused_parameters"? *)
val unused_arguments
: Flambda.function_declarations
-> backend:(module Backend_intf.S)
-> Variable.Set.t