Skip to content

Commit

Permalink
Closure conversion: Filter variables out of subst under lambda (#514)
Browse files Browse the repository at this point in the history
PR #470 propagates substitutions down into lambdas, which works when the
RHS is a constant or symbol but not if it's a variable, since that
variable is now out of scope. This was breaking #485, which produces
variable-for-variable substitutions often. Fortunately,
variable-for-variable substitution under a lambda is also unnecessary
(we already dealt with the free occurrences by making a closure element),
so we can happily just filter out any such bindings.
  • Loading branch information
lukemaurer authored Jun 30, 2021
1 parent a86ad81 commit 6913fb1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions middle_end/flambda/from_lambda/closure_conversion_aux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ module Env = struct
let clear_local_bindings
{ variables = _; globals; simples_to_substitute; backend;
current_unit_id; symbol_for_global'; } =
let simples_to_substitute =
Ident.Map.filter (fun _ simple -> not (Simple.is_var simple))
simples_to_substitute
in
{ variables = Ident.Map.empty;
globals;
simples_to_substitute;
Expand Down

0 comments on commit 6913fb1

Please sign in to comment.