anchor.diff:                      dst=TupleDst},
       CallI = #b_set{anno=Anno,op=call,args=[MFA,TupleDst],dst=Ret},
       Is = [TupleI,CallI],
  -    Blk = #b_blk{is=Is,last=#b_ret{arg=Ret}},
  +
  +    %% When the generator is called within try/catch, the `bad_generator` call
  +    %% must refer to the same landing pad or else we'll break optimizations
  +    %% that assume exceptions are always reflected in the control flow.
  +    Last = case CallLast of
  +               #b_br{fail=CatchLbl} when CatchLbl =/= ?EXCEPTION_BLOCK ->
  +                   #b_br{bool=#b_literal{val=true},
  +                         succ=CatchLbl,fail=CatchLbl};
  +               _ ->
  +                   #b_ret{arg=Ret}
  +           end,
  +
  +    Blk = #b_blk{is=Is,last=Last},
       {L,[{L,Blk}|FailBlk],Count3}.
   
   cg_succeeded(#b_set{dst=OpDst}=I, Succ, Fail, Count0) ->
  
positive.code:             {Acc,Dst,NextBlkL,FailBlk,Count}
      end.
  
  cg_bad_generator([Arg|_], Annos, FailBlk, Count) ->
      case Annos of
          #{Arg := Anno} ->
              cg_bad_generator_1(Anno, Arg, FailBlk, Count);
          #{} ->
              case FailBlk of
                  [{L,_}|_] ->
                      {L,FailBlk,Count};
                  [] ->
                      cg_bad_generator_1(#{}, Arg, FailBlk, Count)
              end
      end.
  
  cg_bad_generator_1(Anno, Arg, FailBlk, Count0) ->
      {L,Count1} = new_block(Count0),
      {TupleDst,Count2} = new_var('@ssa_tuple', Count1),
      {Ret,Count3} = new_var('@ssa_ret', Count2),
  
negative.code: cg_br(Target) ->
      #b_br{bool=#b_literal{val=true},succ=Target,fail=Target}.
  
  cg_atomic_args([A|As], L, Annos, CallLast, FailBlk0, Count0, BlkAcc0, Acc) ->
      case A of
          #b_literal{} ->
              cg_atomic_args(As, L, Annos, CallLast, FailBlk0,
                             Count0, BlkAcc0, [A|Acc]);
          #b_var{} ->
              cg_atomic_args(As, L, Annos, CallLast, FailBlk0,
                             Count0, BlkAcc0, [A|Acc]);
          none ->
              throw(not_possible);
          _ ->
              {BlkAcc,Var,NextBlk,FailBlk,Count} =
                  cg_size_calc_1(L, A, Annos, CallLast, FailBlk0,
                                 Count0, BlkAcc0),
              cg_atomic_args(As, NextBlk, Annos, CallLast, FailBlk,
                                 Count, BlkAcc, [Var|Acc])
      end;
  cg_atomic_args([], NextBlk, _Annos, _CallLast, FailBlk, Count, BlkAcc, Acc) ->
      {reverse(Acc),BlkAcc,NextBlk,FailBlk,Count}.
  
  new_var(Base, Count) ->
  