Skip to content

Commit 95a2dee

Browse files
authored
Keep unused let-bindings for Simplify (#3129)
Keep unused bindings for Simplify
1 parent 54dec2c commit 95a2dee

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

middle_end/flambda2/from_lambda/closure_conversion_aux.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,12 @@ module Let_with_acc = struct
10511051
| Prim (prim, _) -> Flambda_primitive.at_most_generative_effects prim
10521052
| Simple _ | Static_consts _ | Set_of_closures _ | Rec_info _ -> true
10531053
in
1054-
if is_unused_singleton && has_no_effects
1054+
let keep_bindings_for_simplify =
1055+
(* When using Simplify, we don't delete unused bindings here, to increase
1056+
the chance that invalid code is actually simplified to [Invalid]. *)
1057+
not (Flambda_features.classic_mode ())
1058+
in
1059+
if is_unused_singleton && has_no_effects && not keep_bindings_for_simplify
10551060
then acc, body
10561061
else
10571062
let cost_metrics_of_defining_expr =

0 commit comments

Comments
 (0)