anchor.diff:          [_|_]=MissingPaths -> throw({missing_phi_paths, MissingPaths, I});
           [] -> ok
       end.
  -    %% %% The following test is sometimes useful to find missing optimizations.
  -    %% %% It is commented out, though, because it can be triggered by
  -    %% %% by weird but legal code.
  -    %% case ordsets:subtract(ProvidedPaths, RequiredPaths) of
  -    %%     [_|_]=GarbagePaths -> throw({garbage_phi_paths, GarbagePaths, I});
  -    %%     [] -> ok
  -    %% end.
  +%% %% The following test is sometimes useful to find missing optimizations.
  +%% %% It is commented out, though, because it can be triggered by
  +%% %% by weird but legal code.
  +%% case ordsets:subtract(ProvidedPaths, RequiredPaths) of
  +%%     [_|_]=GarbagePaths -> throw({garbage_phi_paths, GarbagePaths, I});
  +%%     [] -> ok
  +%% end.
   
   %% Checks whether all variables used in this phi node are defined in the branch
   %% they arrived on.
   -spec vvars_assert_phi_vars(Phis, I, Id, State) -> ok when
  -    Phis :: list({beam_ssa:argument(), beam_ssa:label()}),
  -    Id :: beam_ssa:label(),
  -    I :: beam_ssa:b_set(),
  -    State :: #vvars{}.
  +      Phis :: list({beam_ssa:argument(), beam_ssa:label()}),
  +      Id :: beam_ssa:label(),
  +      I :: beam_ssa:b_set(),
  +      State :: #vvars{}.
   vvars_assert_phi_vars(Phis, I, Id, #vvars{blocks=Blocks,
                                             branch_def_vars=BranchDefVars}) ->
       Vars = [{Var, From} || {#b_var{}=Var, From} <- Phis],
  -    foreach(fun({#b_var{name=VarName}, From}) ->
  +    foreach(fun({Var, From}) ->
                       BranchKey = {From, Id},
                       case BranchDefVars of
                           #{BranchKey:=DefVars} ->
  -                            case gb_sets:is_member(VarName, DefVars) of
  +                            case gb_sets:is_member(Var, DefVars) of
                                   true -> ok;
  -                                false -> throw({unknown_variable, VarName, I})
  +                                false -> throw({unknown_variable, Var, I})
                               end;
                           #{} ->
  -                            throw({unknown_phi_variable, VarName, BranchKey, I})
  +                            throw({unknown_phi_variable, Var, BranchKey, I})
                       end
               end, Vars),
       Labels = [From || {#b_literal{},From} <- Phis],
  
positive.code:             erlang:raise(Class, Error, Stack)
      end.
  
  -type defined_vars() :: gb_sets:set(beam_ssa:var_name()).
  
  -record(vvars,
          {blocks :: #{ beam_ssa:label() => beam_ssa:b_blk() },
           branch_def_vars :: #{
             %% Describes the variable state at the time of this exact branch (phi
             %% node validation).
             {From :: beam_ssa:label(), To :: beam_ssa:label()} => defined_vars(),
             %% Describes the variable state common to all branches leading to this
             %% label (un/redefined variable validation).
             beam_ssa:label() => defined_vars() },
           defined_vars :: defined_vars()}).
  
  -spec validate_variables(beam_ssa:b_function()) -> ok.
  validate_variables(#b_function{ args = Args, bs = Blocks }) ->
      %% Prefill the mapping with function arguments.
      ArgNames = vvars_get_varnames(Args),
      DefVars = gb_sets:from_list(ArgNames),
      Entry = 0,
  
      State = #vvars{blocks = Blocks,
                     branch_def_vars = #{ Entry => DefVars },
                     defined_vars = DefVars},
      ok = vvars_assert_unique(Blocks, ArgNames),
      vvars_phi_nodes(vvars_block(Entry, State)).
  
  %% Checks the uniqueness of all variables across all blocks.
  -spec vvars_assert_unique(Blocks, [beam_ssa:var_name()]) -> ok when
        Blocks :: #{ beam_ssa:label() => beam_ssa:b_blk() }.
  vvars_assert_unique(Blocks, Args) ->
      BlockIs = [Is || #b_blk{is=Is} <- maps:values(Blocks)],
  
negative.code: %% Checks whether all paths leading to this phi node are represented, and that
  %% it doesn't reference any non-existent paths.
  -spec vvars_assert_phi_paths(Phis, I, Id, State) -> ok when
        Phis :: list({beam_ssa:argument(), beam_ssa:label()}),
        Id :: beam_ssa:label(),
        I :: beam_ssa:b_set(),
        State :: #vvars{}.
  vvars_assert_phi_paths(Phis, I, Id, State) ->
      BranchKeys = maps:keys(State#vvars.branch_def_vars),
      RequiredPaths = ordsets:from_list([From || {From, To} <- BranchKeys, To =:= Id]),
  