Skip to content

Commit

Permalink
Don't try to handle regions in Flambda.fold_lets_option
Browse files Browse the repository at this point in the history
It used to be much more necessary, but no more, and it interferes with the
handling of regions using `enter_region`.
  • Loading branch information
lukemaurer committed Apr 18, 2023
1 parent 907627d commit 66132fb
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions middle_end/flambda/flambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -911,10 +911,6 @@ module With_free_variables = struct
free_vars_of_body;
}

let create_region (t : expr t) =
let Expr (body, fv) = t in
Expr (Region body, fv)

let expr (t : expr t) =
match t with
| Expr (expr, free_vars) -> Named (Expr expr, free_vars)
Expand All @@ -939,7 +935,7 @@ let fold_lets_option
let finish ~last_body ~acc ~rev_lets =
let module W = With_free_variables in
let acc, t =
List.fold_left (fun (acc, t) (has_region, var, defining_expr) ->
List.fold_left (fun (acc, t) (var, defining_expr) ->
let free_vars_of_body = W.free_variables t in
let acc, var, defining_expr =
filter_defining_expr acc var defining_expr free_vars_of_body
Expand All @@ -950,7 +946,6 @@ let fold_lets_option
| Some defining_expr ->
W.of_expr (W.create_let_reusing_body var defining_expr t)
in
let t = if has_region then W.create_region t else t in
acc, t)
(acc, W.of_expr last_body)
rev_lets
Expand All @@ -959,13 +954,11 @@ let fold_lets_option
in
let rec loop (t : t) ~acc ~rev_lets =
match t with
| Let { var; defining_expr; body; _ }
| Region (Let { var; defining_expr; body; _ }) ->
| Let { var; defining_expr; body; _ } ->
let acc, var, defining_expr =
for_defining_expr acc var defining_expr
in
let has_region = match t with Region _ -> true | _ -> false in
let rev_lets = (has_region, var, defining_expr) :: rev_lets in
let rev_lets = (var, defining_expr) :: rev_lets in
loop body ~acc ~rev_lets
| t ->
let last_body, acc = for_last_body acc t in
Expand Down

0 comments on commit 66132fb

Please sign in to comment.