| ... | @@ -389,6 +389,10 @@ const Writer = struct { | ... | @@ -389,6 +389,10 @@ const Writer = struct { |
| 389 | const ty_pl = w.air.instructions.items(.data)[inst].ty_pl; | 389 | const ty_pl = w.air.instructions.items(.data)[inst].ty_pl; |
| 390 | const extra = w.air.extraData(Air.Block, ty_pl.payload); | 390 | const extra = w.air.extraData(Air.Block, ty_pl.payload); |
| 391 | const body = w.air.extra[extra.end..][0..extra.data.body_len]; | 391 | const body = w.air.extra[extra.end..][0..extra.data.body_len]; |
| | 392 | const liveness_block = if (w.liveness) |liveness| |
| | 393 | liveness.getBlock(inst) |
| | 394 | else |
| | 395 | Liveness.BlockSlices{ .deaths = &.{} }; |
| 392 | | 396 | |
| 393 | try w.writeType(s, w.air.getRefType(ty_pl.ty)); | 397 | try w.writeType(s, w.air.getRefType(ty_pl.ty)); |
| 394 | if (w.skip_body) return s.writeAll(", ..."); | 398 | if (w.skip_body) return s.writeAll(", ..."); |
| ... | @@ -399,6 +403,10 @@ const Writer = struct { | ... | @@ -399,6 +403,10 @@ const Writer = struct { |
| 399 | w.indent = old_indent; | 403 | w.indent = old_indent; |
| 400 | try s.writeByteNTimes(' ', w.indent); | 404 | try s.writeByteNTimes(' ', w.indent); |
| 401 | try s.writeAll("}"); | 405 | try s.writeAll("}"); |
| | 406 | |
| | 407 | for (liveness_block.deaths) |operand| { |
| | 408 | try s.print(" %{d}!", .{operand}); |
| | 409 | } |
| 402 | } | 410 | } |
| 403 | | 411 | |
| 404 | fn writeLoop(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 412 | fn writeLoop(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { |
| ... | @@ -737,22 +745,44 @@ const Writer = struct { | ... | @@ -737,22 +745,44 @@ const Writer = struct { |
| 737 | const pl_op = w.air.instructions.items(.data)[inst].pl_op; | 745 | const pl_op = w.air.instructions.items(.data)[inst].pl_op; |
| 738 | const extra = w.air.extraData(Air.Try, pl_op.payload); | 746 | const extra = w.air.extraData(Air.Try, pl_op.payload); |
| 739 | const body = w.air.extra[extra.end..][0..extra.data.body_len]; | 747 | const body = w.air.extra[extra.end..][0..extra.data.body_len]; |
| | 748 | const liveness_condbr = if (w.liveness) |liveness| |
| | 749 | liveness.getCondBr(inst) |
| | 750 | else |
| | 751 | Liveness.CondBrSlices{ .then_deaths = &.{}, .else_deaths = &.{} }; |
| 740 | | 752 | |
| 741 | try w.writeOperand(s, inst, 0, pl_op.operand); | 753 | try w.writeOperand(s, inst, 0, pl_op.operand); |
| 742 | if (w.skip_body) return s.writeAll(", ..."); | 754 | if (w.skip_body) return s.writeAll(", ..."); |
| 743 | try s.writeAll(", {\n"); | 755 | try s.writeAll(", {\n"); |
| 744 | const old_indent = w.indent; | 756 | const old_indent = w.indent; |
| 745 | w.indent += 2; | 757 | w.indent += 2; |
| | 758 | |
| | 759 | if (liveness_condbr.else_deaths.len != 0) { |
| | 760 | try s.writeByteNTimes(' ', w.indent); |
| | 761 | for (liveness_condbr.else_deaths, 0..) |operand, i| { |
| | 762 | if (i != 0) try s.writeAll(" "); |
| | 763 | try s.print("%{d}!", .{operand}); |
| | 764 | } |
| | 765 | try s.writeAll("\n"); |
| | 766 | } |
| 746 | try w.writeBody(s, body); | 767 | try w.writeBody(s, body); |
| | 768 | |
| 747 | w.indent = old_indent; | 769 | w.indent = old_indent; |
| 748 | try s.writeByteNTimes(' ', w.indent); | 770 | try s.writeByteNTimes(' ', w.indent); |
| 749 | try s.writeAll("}"); | 771 | try s.writeAll("}"); |
| | 772 | |
| | 773 | for (liveness_condbr.then_deaths) |operand| { |
| | 774 | try s.print(" %{d}!", .{operand}); |
| | 775 | } |
| 750 | } | 776 | } |
| 751 | | 777 | |
| 752 | fn writeTryPtr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 778 | fn writeTryPtr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { |
| 753 | const ty_pl = w.air.instructions.items(.data)[inst].ty_pl; | 779 | const ty_pl = w.air.instructions.items(.data)[inst].ty_pl; |
| 754 | const extra = w.air.extraData(Air.TryPtr, ty_pl.payload); | 780 | const extra = w.air.extraData(Air.TryPtr, ty_pl.payload); |
| 755 | const body = w.air.extra[extra.end..][0..extra.data.body_len]; | 781 | const body = w.air.extra[extra.end..][0..extra.data.body_len]; |
| | 782 | const liveness_condbr = if (w.liveness) |liveness| |
| | 783 | liveness.getCondBr(inst) |
| | 784 | else |
| | 785 | Liveness.CondBrSlices{ .then_deaths = &.{}, .else_deaths = &.{} }; |
| 756 | | 786 | |
| 757 | try w.writeOperand(s, inst, 0, extra.data.ptr); | 787 | try w.writeOperand(s, inst, 0, extra.data.ptr); |
| 758 | | 788 | |
| ... | @@ -762,10 +792,24 @@ const Writer = struct { | ... | @@ -762,10 +792,24 @@ const Writer = struct { |
| 762 | try s.writeAll(", {\n"); | 792 | try s.writeAll(", {\n"); |
| 763 | const old_indent = w.indent; | 793 | const old_indent = w.indent; |
| 764 | w.indent += 2; | 794 | w.indent += 2; |
| | 795 | |
| | 796 | if (liveness_condbr.else_deaths.len != 0) { |
| | 797 | try s.writeByteNTimes(' ', w.indent); |
| | 798 | for (liveness_condbr.else_deaths, 0..) |operand, i| { |
| | 799 | if (i != 0) try s.writeAll(" "); |
| | 800 | try s.print("%{d}!", .{operand}); |
| | 801 | } |
| | 802 | try s.writeAll("\n"); |
| | 803 | } |
| 765 | try w.writeBody(s, body); | 804 | try w.writeBody(s, body); |
| | 805 | |
| 766 | w.indent = old_indent; | 806 | w.indent = old_indent; |
| 767 | try s.writeByteNTimes(' ', w.indent); | 807 | try s.writeByteNTimes(' ', w.indent); |
| 768 | try s.writeAll("}"); | 808 | try s.writeAll("}"); |
| | 809 | |
| | 810 | for (liveness_condbr.then_deaths) |operand| { |
| | 811 | try s.print(" %{d}!", .{operand}); |
| | 812 | } |
| 769 | } | 813 | } |
| 770 | | 814 | |
| 771 | fn writeCondBr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 815 | fn writeCondBr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { |