| ... | ... | @@ -750,6 +750,9 @@ const Writer = struct { |
| 750 | 750 | fn writeSwitchBr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { |
| 751 | 751 | const pl_op = w.air.instructions.items(.data)[inst].pl_op; |
| 752 | 752 | const switch_br = w.air.extraData(Air.SwitchBr, pl_op.payload); |
| 753 | const liveness = w.liveness.getSwitchBr(w.gpa, inst, switch_br.data.cases_len + 1) catch |
| 754 | @panic("out of memory"); |
| 755 | defer w.gpa.free(liveness.deaths); |
| 753 | 756 | var extra_index: usize = switch_br.end; |
| 754 | 757 | var case_i: u32 = 0; |
| 755 | 758 | |
| ... | ... | @@ -770,6 +773,17 @@ const Writer = struct { |
| 770 | 773 | } |
| 771 | 774 | try s.writeAll("] => {\n"); |
| 772 | 775 | w.indent += 2; |
| 776 | |
| 777 | const deaths = liveness.deaths[case_i]; |
| 778 | if (deaths.len != 0) { |
| 779 | try s.writeByteNTimes(' ', w.indent); |
| 780 | for (deaths) |operand, i| { |
| 781 | if (i != 0) try s.writeAll(" "); |
| 782 | try s.print("%{d}!", .{operand}); |
| 783 | } |
| 784 | try s.writeAll("\n"); |
| 785 | } |
| 786 | |
| 773 | 787 | try w.writeBody(s, case_body); |
| 774 | 788 | w.indent -= 2; |
| 775 | 789 | try s.writeByteNTimes(' ', w.indent); |
| ... | ... | @@ -780,6 +794,17 @@ const Writer = struct { |
| 780 | 794 | if (else_body.len != 0) { |
| 781 | 795 | try s.writeAll(", else => {\n"); |
| 782 | 796 | w.indent += 2; |
| 797 | |
| 798 | const deaths = liveness.deaths[liveness.deaths.len - 1]; |
| 799 | if (deaths.len != 0) { |
| 800 | try s.writeByteNTimes(' ', w.indent); |
| 801 | for (deaths) |operand, i| { |
| 802 | if (i != 0) try s.writeAll(" "); |
| 803 | try s.print("%{d}!", .{operand}); |
| 804 | } |
| 805 | try s.writeAll("\n"); |
| 806 | } |
| 807 | |
| 783 | 808 | try w.writeBody(s, else_body); |
| 784 | 809 | w.indent -= 2; |
| 785 | 810 | try s.writeByteNTimes(' ', w.indent); |