summaryrefslogtreecommitdiff
path: root/middle_end
diff options
context:
space:
mode:
authorTom Kelly <ctk21@cl.cam.ac.uk>2020-04-27 10:33:55 +0100
committerTom Kelly <ctk21@cl.cam.ac.uk>2020-04-27 10:33:55 +0100
commit3dc5c65d2574fb4d460708bca80b92000e20f245 (patch)
treeb92bec849e0e5e8adaa99b573d76dacb94fcf585 /middle_end
parent49f21b573de0f333e92f933c27651e1f0649891c (diff)
parent455bd0ffae85a9b63cb331ac532ea2ab52fe418c (diff)
downloadocaml-3dc5c65d2574fb4d460708bca80b92000e20f245.tar.gz
Merge commit '455bd0ffae85a9b63cb331ac532ea2ab52fe418c' into parallel_minor_gc_4_10
Diffstat (limited to 'middle_end')
-rw-r--r--middle_end/closure/closure.ml8
-rw-r--r--middle_end/flambda/closure_conversion.ml4
-rw-r--r--middle_end/flambda/effect_analysis.ml6
-rw-r--r--middle_end/flambda/export_info_for_pack.ml2
-rw-r--r--middle_end/flambda/flambda.ml10
-rw-r--r--middle_end/flambda/flambda_invariants.ml4
-rw-r--r--middle_end/flambda/flambda_iterators.ml4
-rw-r--r--middle_end/flambda/flambda_to_clambda.ml2
-rw-r--r--middle_end/flambda/inconstant_idents.ml4
-rw-r--r--middle_end/flambda/inlining_cost.ml2
-rw-r--r--middle_end/flambda/ref_to_variables.ml4
-rw-r--r--middle_end/flambda/simple_value_approx.ml2
-rw-r--r--middle_end/flambda/un_anf.ml8
13 files changed, 29 insertions, 31 deletions
diff --git a/middle_end/closure/closure.ml b/middle_end/closure/closure.ml
index 2b27d05b1d..e9e1928d1e 100644
--- a/middle_end/closure/closure.ml
+++ b/middle_end/closure/closure.ml
@@ -189,7 +189,7 @@ let lambda_smaller lam threshold =
size := !size+2 ;
lambda_size lam)
sw ;
- Misc.may lambda_size d
+ Option.iter lambda_size d
| Ustaticfail (_,args) -> lambda_list_size args
| Ucatch(_, _, body, handler) ->
incr size; lambda_size body; lambda_size handler
@@ -632,7 +632,7 @@ let rec substitute loc ((backend, fpc) as st) sb rn ulam =
Ustringswitch
(substitute loc st sb rn arg,
List.map (fun (s,act) -> s,substitute loc st sb rn act) sw,
- Misc.may_map (substitute loc st sb rn) d)
+ Option.map (substitute loc st sb rn) d)
| Ustaticfail (nfail, args) ->
let nfail =
match rn with
@@ -1140,7 +1140,7 @@ let rec close ({ backend; fenv; cenv } as env) lam =
s,uact)
sw in
let ud =
- Misc.may_map
+ Option.map
(fun d ->
let ud,_ = close env d in
ud) d in
@@ -1457,7 +1457,7 @@ let collect_exported_structured_constants a =
| Ustringswitch (u,sw,d) ->
ulam u ;
List.iter (fun (_,act) -> ulam act) sw ;
- Misc.may ulam d
+ Option.iter ulam d
| Ustaticfail (_, ul) -> List.iter ulam ul
| Ucatch (_, _, u1, u2)
| Utrywith (u1, _, u2)
diff --git a/middle_end/flambda/closure_conversion.ml b/middle_end/flambda/closure_conversion.ml
index 4aa702fb4f..8a8784e061 100644
--- a/middle_end/flambda/closure_conversion.ml
+++ b/middle_end/flambda/closure_conversion.ml
@@ -502,14 +502,14 @@ let rec close t env (lam : Lambda.lambda) : Flambda.t =
consts = List.map aux sw.sw_consts;
numblocks = nums sw.sw_numblocks sw.sw_blocks sw.sw_failaction;
blocks = List.map aux sw.sw_blocks;
- failaction = Misc.may_map (close t env) sw.sw_failaction;
+ failaction = Option.map (close t env) sw.sw_failaction;
}))
| Lstringswitch (arg, sw, def, _) ->
let scrutinee = Variable.create Names.string_switch in
Flambda.create_let scrutinee (Expr (close t env arg))
(String_switch (scrutinee,
List.map (fun (s, e) -> s, close t env e) sw,
- Misc.may_map (close t env) def))
+ Option.map (close t env) def))
| Lstaticraise (i, args) ->
Lift_code.lifting_helper (close_list t env args)
~evaluation_order:`Right_to_left
diff --git a/middle_end/flambda/effect_analysis.ml b/middle_end/flambda/effect_analysis.ml
index d0cbd44180..2ddba764bc 100644
--- a/middle_end/flambda/effect_analysis.ml
+++ b/middle_end/flambda/effect_analysis.ml
@@ -37,12 +37,10 @@ let rec no_effects (flam : Flambda.t) =
let aux (_, flam) = no_effects flam in
List.for_all aux sw.blocks
&& List.for_all aux sw.consts
- && Misc.Stdlib.Option.value_default no_effects sw.failaction
- ~default:true
+ && Option.fold ~some:no_effects ~none:true sw.failaction
| String_switch (_, sw, def) ->
List.for_all (fun (_, lam) -> no_effects lam) sw
- && Misc.Stdlib.Option.value_default no_effects def
- ~default:true
+ && Option.fold ~some:no_effects ~none:true def
| Static_catch (_, _, body, _) | Try_with (body, _, _) ->
(* If there is a [raise] in [body], the whole [Try_with] may have an
effect, so there is no need to test the handler. *)
diff --git a/middle_end/flambda/export_info_for_pack.ml b/middle_end/flambda/export_info_for_pack.ml
index 42a8155347..ebed559369 100644
--- a/middle_end/flambda/export_info_for_pack.ml
+++ b/middle_end/flambda/export_info_for_pack.ml
@@ -89,7 +89,7 @@ let import_set_of_closures units pack
Closure_id.Map.map (import_approx_for_pack units pack)
set_of_closures.results;
aliased_symbol =
- Misc.may_map
+ Option.map
(import_symbol_for_pack units pack)
set_of_closures.aliased_symbol;
}
diff --git a/middle_end/flambda/flambda.ml b/middle_end/flambda/flambda.ml
index 243e2e3f9c..70adfcb939 100644
--- a/middle_end/flambda/flambda.ml
+++ b/middle_end/flambda/flambda.ml
@@ -565,11 +565,11 @@ let rec variables_usage ?ignore_uses_as_callee ?ignore_uses_as_argument
free_variable scrutinee;
List.iter (fun (_, e) -> aux e) switch.consts;
List.iter (fun (_, e) -> aux e) switch.blocks;
- Misc.may aux switch.failaction
+ Option.iter aux switch.failaction
| String_switch (scrutinee, cases, failaction) ->
free_variable scrutinee;
List.iter (fun (_, e) -> aux e) cases;
- Misc.may aux failaction
+ Option.iter aux failaction
| Static_raise (_, es) ->
List.iter free_variable es
| Static_catch (_, vars, e1, e2) ->
@@ -789,10 +789,10 @@ let iter_general ~toplevel f f_named maybe_named =
| Switch (_, sw) ->
List.iter (fun (_,l) -> aux l) sw.consts;
List.iter (fun (_,l) -> aux l) sw.blocks;
- Misc.may aux sw.failaction
+ Option.iter aux sw.failaction
| String_switch (_, sw, def) ->
List.iter (fun (_,l) -> aux l) sw;
- Misc.may aux def
+ Option.iter aux def
and aux_named (named : named) =
f_named named;
match named with
@@ -1138,7 +1138,7 @@ let create_set_of_closures ~function_decls ~free_vars ~specialised_args
This would be true when the function is known never to have
been inlined.
- Note that something like that may maybe enforcable in
+ Note that something like that may maybe enforceable in
inline_and_simplify, but there is no way to do that on other
passes.
diff --git a/middle_end/flambda/flambda_invariants.ml b/middle_end/flambda/flambda_invariants.ml
index 250a2e9af7..6c2b572d96 100644
--- a/middle_end/flambda/flambda_invariants.ml
+++ b/middle_end/flambda/flambda_invariants.ml
@@ -213,14 +213,14 @@ let variable_and_symbol_invariants (program : Flambda.program) =
ignore_int n;
loop env e)
(consts @ blocks);
- Misc.may (loop env) failaction
+ Option.iter (loop env) failaction
| String_switch (arg, cases, e_opt) ->
check_variable_is_bound env arg;
List.iter (fun (label, case) ->
ignore_string label;
loop env case)
cases;
- Misc.may (loop env) e_opt
+ Option.iter (loop env) e_opt
| Static_raise (static_exn, es) ->
ignore_static_exception static_exn;
List.iter (check_variable_is_bound env) es
diff --git a/middle_end/flambda/flambda_iterators.ml b/middle_end/flambda/flambda_iterators.ml
index a69575da63..6edc4bba3b 100644
--- a/middle_end/flambda/flambda_iterators.ml
+++ b/middle_end/flambda/flambda_iterators.ml
@@ -32,10 +32,10 @@ let apply_on_subexpressions f f_named (flam : Flambda.t) =
| Switch (_, sw) ->
List.iter (fun (_,l) -> f l) sw.consts;
List.iter (fun (_,l) -> f l) sw.blocks;
- Misc.may f sw.failaction
+ Option.iter f sw.failaction
| String_switch (_, sw, def) ->
List.iter (fun (_,l) -> f l) sw;
- Misc.may f def
+ Option.iter f def
| Static_catch (_,_,f1,f2) ->
f f1; f f2;
| Try_with (f1,_,f2) ->
diff --git a/middle_end/flambda/flambda_to_clambda.ml b/middle_end/flambda/flambda_to_clambda.ml
index 5ca40f4b15..882c198e48 100644
--- a/middle_end/flambda/flambda_to_clambda.ml
+++ b/middle_end/flambda/flambda_to_clambda.ml
@@ -313,7 +313,7 @@ let rec to_clambda t env (flam : Flambda.t) : Clambda.ulambda =
| String_switch (arg, sw, def) ->
let arg = subst_var env arg in
let sw = List.map (fun (s, e) -> s, to_clambda t env e) sw in
- let def = Misc.may_map (to_clambda t env) def in
+ let def = Option.map (to_clambda t env) def in
Ustringswitch (arg, sw, def)
| Static_raise (static_exn, args) ->
Ustaticfail (Static_exception.to_int static_exn,
diff --git a/middle_end/flambda/inconstant_idents.ml b/middle_end/flambda/inconstant_idents.ml
index 59f8aa8a8c..28efb3e94a 100644
--- a/middle_end/flambda/inconstant_idents.ml
+++ b/middle_end/flambda/inconstant_idents.ml
@@ -286,12 +286,12 @@ module Inconstants (P:Param) (Backend:Backend_intf.S) = struct
mark_var arg curr;
List.iter (fun (_,l) -> mark_loop ~toplevel [] l) sw.consts;
List.iter (fun (_,l) -> mark_loop ~toplevel [] l) sw.blocks;
- Misc.may (fun l -> mark_loop ~toplevel [] l) sw.failaction
+ Option.iter (fun l -> mark_loop ~toplevel [] l) sw.failaction
| String_switch (arg,sw,def) ->
mark_curr curr;
mark_var arg curr;
List.iter (fun (_,l) -> mark_loop ~toplevel [] l) sw;
- Misc.may (fun l -> mark_loop ~toplevel [] l) def
+ Option.iter (fun l -> mark_loop ~toplevel [] l) def
| Send { kind = _; meth; obj; args; dbg = _; } ->
mark_curr curr;
mark_var meth curr;
diff --git a/middle_end/flambda/inlining_cost.ml b/middle_end/flambda/inlining_cost.ml
index 33e870f90a..3ca1d2225a 100644
--- a/middle_end/flambda/inlining_cost.ml
+++ b/middle_end/flambda/inlining_cost.ml
@@ -99,7 +99,7 @@ let lambda_smaller' lam ~than:threshold =
size := !size + 2;
lambda_size lam)
sw;
- Misc.may lambda_size def
+ Option.iter lambda_size def
| Static_raise _ -> ()
| Static_catch (_, _, body, handler) ->
incr size; lambda_size body; lambda_size handler
diff --git a/middle_end/flambda/ref_to_variables.ml b/middle_end/flambda/ref_to_variables.ml
index f65e015109..746374e885 100644
--- a/middle_end/flambda/ref_to_variables.ml
+++ b/middle_end/flambda/ref_to_variables.ml
@@ -60,11 +60,11 @@ let variables_not_used_as_local_reference (tree:Flambda.t) =
set := Variable.Set.add cond !set;
List.iter (fun (_, branch) -> loop branch) consts;
List.iter (fun (_, branch) -> loop branch) blocks;
- Misc.may loop failaction
+ Option.iter loop failaction
| String_switch (cond, branches, default) ->
set := Variable.Set.add cond !set;
List.iter (fun (_, branch) -> loop branch) branches;
- Misc.may loop default
+ Option.iter loop default
| Static_catch (_, _, body, handler) ->
loop body;
loop handler
diff --git a/middle_end/flambda/simple_value_approx.ml b/middle_end/flambda/simple_value_approx.ml
index 34fc5ce056..fcd8e4d77c 100644
--- a/middle_end/flambda/simple_value_approx.ml
+++ b/middle_end/flambda/simple_value_approx.ml
@@ -290,7 +290,7 @@ let value_closure ?closure_var ?set_of_closures_var ?set_of_closures_symbol
let approx_set_of_closures =
{ descr = Value_set_of_closures value_set_of_closures;
var = set_of_closures_var;
- symbol = Misc.may_map (fun s -> s, None) set_of_closures_symbol;
+ symbol = Option.map (fun s -> s, None) set_of_closures_symbol;
}
in
let value_closure =
diff --git a/middle_end/flambda/un_anf.ml b/middle_end/flambda/un_anf.ml
index 19b04d85a4..c9a095b5cb 100644
--- a/middle_end/flambda/un_anf.ml
+++ b/middle_end/flambda/un_anf.ml
@@ -152,7 +152,7 @@ let make_var_info (clam : Clambda.ulambda) : var_info =
ignore_string str;
loop branch)
branches;
- Misc.may loop default
+ Option.iter loop default
| Ustaticfail (static_exn, args) ->
ignore_int static_exn;
List.iter loop args
@@ -354,7 +354,7 @@ let let_bound_vars_that_can_be_moved var_info (clam : Clambda.ulambda) =
loop branch)
branches;
let_stack := [];
- Misc.may loop default;
+ Option.iter loop default;
let_stack := []
| Ustaticfail (static_exn, args) ->
ignore_int static_exn;
@@ -516,7 +516,7 @@ let rec substitute_let_moveable is_let_moveable env (clam : Clambda.ulambda)
branches
in
let default =
- Misc.may_map (substitute_let_moveable is_let_moveable env) default
+ Option.map (substitute_let_moveable is_let_moveable env) default
in
Ustringswitch (cond, branches, default)
| Ustaticfail (n, args) ->
@@ -735,7 +735,7 @@ let rec un_anf_and_moveable var_info env (clam : Clambda.ulambda)
List.map (fun (s, branch) -> s, un_anf var_info env branch)
branches
in
- let default = Misc.may_map (un_anf var_info env) default in
+ let default = Option.map (un_anf var_info env) default in
Ustringswitch (cond, branches, default), Fixed
| Ustaticfail (n, args) ->
let args = un_anf_list var_info env args in