authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-08-10 03:25:35-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-11 11:01:47-07:00
log8b9161179d08a3f1dc22ea61e6165a0c638bfae3
tree9766bd828e3db022e50808c89c250c3e01b6609b
parentb835fd90cef1447904d3b009c9662ba4c0ea77d4

Sema: avoid deleting runtime side-effects in comptime initializers

Closes #16744

4 files changed, 190 insertions(+), 84 deletions(-)

src/Sema.zig+136-73
...@@ -4491,7 +4491,7 @@ fn validateUnionInit(...@@ -4491,7 +4491,7 @@ fn validateUnionInit(
4491 _ = try sema.unionFieldIndex(block, union_ty, field_name, field_src);4491 _ = try sema.unionFieldIndex(block, union_ty, field_name, field_src);
4492 const air_tags = sema.air_instructions.items(.tag);4492 const air_tags = sema.air_instructions.items(.tag);
4493 const air_datas = sema.air_instructions.items(.data);4493 const air_datas = sema.air_instructions.items(.data);
4494 const field_ptr_air_ref = sema.inst_map.get(field_ptr).?;4494 const field_ptr_ref = sema.inst_map.get(field_ptr).?;
44954495
4496 // Our task here is to determine if the union is comptime-known. In such case,4496 // Our task here is to determine if the union is comptime-known. In such case,
4497 // we erase the runtime AIR instructions for initializing the union, and replace4497 // we erase the runtime AIR instructions for initializing the union, and replace
...@@ -4521,31 +4521,25 @@ fn validateUnionInit(...@@ -4521,31 +4521,25 @@ fn validateUnionInit(
4521 var make_runtime = false;4521 var make_runtime = false;
4522 while (block_index > 0) : (block_index -= 1) {4522 while (block_index > 0) : (block_index -= 1) {
4523 const store_inst = block.instructions.items[block_index];4523 const store_inst = block.instructions.items[block_index];
4524 if (Air.indexToRef(store_inst) == field_ptr_air_ref) break;4524 if (Air.indexToRef(store_inst) == field_ptr_ref) break;
4525 switch (air_tags[store_inst]) {4525 switch (air_tags[store_inst]) {
4526 .store, .store_safe => {},4526 .store, .store_safe => {},
4527 else => continue,4527 else => continue,
4528 }4528 }
4529 const bin_op = air_datas[store_inst].bin_op;4529 const bin_op = air_datas[store_inst].bin_op;
4530 var lhs = bin_op.lhs;4530 var ptr_ref = bin_op.lhs;
4531 if (Air.refToIndex(lhs)) |lhs_index| {4531 if (Air.refToIndex(ptr_ref)) |ptr_inst| if (air_tags[ptr_inst] == .bitcast) {
4532 if (air_tags[lhs_index] == .bitcast) {4532 ptr_ref = air_datas[ptr_inst].ty_op.operand;
4533 lhs = air_datas[lhs_index].ty_op.operand;4533 };
4534 block_index -= 1;4534 if (ptr_ref != field_ptr_ref) continue;
4535 }4535 first_block_index = @min(if (Air.refToIndex(field_ptr_ref)) |field_ptr_inst|
4536 }4536 std.mem.lastIndexOfScalar(
4537 if (lhs != field_ptr_air_ref) continue;4537 Air.Inst.Index,
4538 while (block_index > 0) : (block_index -= 1) {4538 block.instructions.items[0..block_index],
4539 const block_inst = block.instructions.items[block_index - 1];4539 field_ptr_inst,
4540 if (air_tags[block_inst] != .dbg_stmt) break;4540 ).?
4541 }4541 else
4542 if (block_index > 0 and4542 block_index, first_block_index);
4543 field_ptr_air_ref == Air.indexToRef(block.instructions.items[block_index - 1]))
4544 {
4545 first_block_index = @min(first_block_index, block_index - 1);
4546 } else {
4547 first_block_index = @min(first_block_index, block_index);
4548 }
4549 init_val = try sema.resolveMaybeUndefValAllowVariablesMaybeRuntime(bin_op.rhs, &make_runtime);4543 init_val = try sema.resolveMaybeUndefValAllowVariablesMaybeRuntime(bin_op.rhs, &make_runtime);
4550 break;4544 break;
4551 }4545 }
...@@ -4557,7 +4551,29 @@ fn validateUnionInit(...@@ -4557,7 +4551,29 @@ fn validateUnionInit(
4557 if (init_val) |val| {4551 if (init_val) |val| {
4558 // Our task is to delete all the `field_ptr` and `store` instructions, and insert4552 // Our task is to delete all the `field_ptr` and `store` instructions, and insert
4559 // instead a single `store` to the result ptr with a comptime union value.4553 // instead a single `store` to the result ptr with a comptime union value.
4560 block.instructions.shrinkRetainingCapacity(first_block_index);4554 block_index = first_block_index;
4555 for (block.instructions.items[first_block_index..]) |cur_inst| {
4556 switch (air_tags[cur_inst]) {
4557 .struct_field_ptr,
4558 .struct_field_ptr_index_0,
4559 .struct_field_ptr_index_1,
4560 .struct_field_ptr_index_2,
4561 .struct_field_ptr_index_3,
4562 => if (Air.indexToRef(cur_inst) == field_ptr_ref) continue,
4563 .bitcast => if (air_datas[cur_inst].ty_op.operand == field_ptr_ref) continue,
4564 .store, .store_safe => {
4565 var ptr_ref = air_datas[cur_inst].bin_op.lhs;
4566 if (Air.refToIndex(ptr_ref)) |ptr_inst| if (air_tags[ptr_inst] == .bitcast) {
4567 ptr_ref = air_datas[ptr_inst].ty_op.operand;
4568 };
4569 if (ptr_ref == field_ptr_ref) continue;
4570 },
4571 else => {},
4572 }
4573 block.instructions.items[block_index] = cur_inst;
4574 block_index += 1;
4575 }
4576 block.instructions.shrinkRetainingCapacity(block_index);
45614577
4562 var union_val = try mod.intern(.{ .un = .{4578 var union_val = try mod.intern(.{ .un = .{
4563 .ty = union_ty.toIntern(),4579 .ty = union_ty.toIntern(),
...@@ -4590,6 +4606,9 @@ fn validateStructInit(...@@ -4590,6 +4606,9 @@ fn validateStructInit(
4590 const gpa = sema.gpa;4606 const gpa = sema.gpa;
4591 const ip = &mod.intern_pool;4607 const ip = &mod.intern_pool;
45924608
4609 const field_indices = try gpa.alloc(u32, instrs.len);
4610 defer gpa.free(field_indices);
4611
4593 // Maps field index to field_ptr index of where it was already initialized.4612 // Maps field index to field_ptr index of where it was already initialized.
4594 const found_fields = try gpa.alloc(Zir.Inst.Index, struct_ty.structFieldCount(mod));4613 const found_fields = try gpa.alloc(Zir.Inst.Index, struct_ty.structFieldCount(mod));
4595 defer gpa.free(found_fields);4614 defer gpa.free(found_fields);
...@@ -4597,7 +4616,7 @@ fn validateStructInit(...@@ -4597,7 +4616,7 @@ fn validateStructInit(
45974616
4598 var struct_ptr_zir_ref: Zir.Inst.Ref = undefined;4617 var struct_ptr_zir_ref: Zir.Inst.Ref = undefined;
45994618
4600 for (instrs) |field_ptr| {4619 for (instrs, field_indices) |field_ptr, *field_index| {
4601 const field_ptr_data = sema.code.instructions.items(.data)[field_ptr].pl_node;4620 const field_ptr_data = sema.code.instructions.items(.data)[field_ptr].pl_node;
4602 const field_src: LazySrcLoc = .{ .node_offset_initializer = field_ptr_data.src_node };4621 const field_src: LazySrcLoc = .{ .node_offset_initializer = field_ptr_data.src_node };
4603 const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data;4622 const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data;
...@@ -4606,12 +4625,12 @@ fn validateStructInit(...@@ -4606,12 +4625,12 @@ fn validateStructInit(
4606 gpa,4625 gpa,
4607 sema.code.nullTerminatedString(field_ptr_extra.field_name_start),4626 sema.code.nullTerminatedString(field_ptr_extra.field_name_start),
4608 );4627 );
4609 const field_index = if (struct_ty.isTuple(mod))4628 field_index.* = if (struct_ty.isTuple(mod))
4610 try sema.tupleFieldIndex(block, struct_ty, field_name, field_src)4629 try sema.tupleFieldIndex(block, struct_ty, field_name, field_src)
4611 else4630 else
4612 try sema.structFieldIndex(block, struct_ty, field_name, field_src);4631 try sema.structFieldIndex(block, struct_ty, field_name, field_src);
4613 if (found_fields[field_index] != 0) {4632 if (found_fields[field_index.*] != 0) {
4614 const other_field_ptr = found_fields[field_index];4633 const other_field_ptr = found_fields[field_index.*];
4615 const other_field_ptr_data = sema.code.instructions.items(.data)[other_field_ptr].pl_node;4634 const other_field_ptr_data = sema.code.instructions.items(.data)[other_field_ptr].pl_node;
4616 const other_field_src: LazySrcLoc = .{ .node_offset_initializer = other_field_ptr_data.src_node };4635 const other_field_src: LazySrcLoc = .{ .node_offset_initializer = other_field_ptr_data.src_node };
4617 const msg = msg: {4636 const msg = msg: {
...@@ -4622,7 +4641,7 @@ fn validateStructInit(...@@ -4622,7 +4641,7 @@ fn validateStructInit(
4622 };4641 };
4623 return sema.failWithOwnedErrorMsg(msg);4642 return sema.failWithOwnedErrorMsg(msg);
4624 }4643 }
4625 found_fields[field_index] = field_ptr;4644 found_fields[field_index.*] = field_ptr;
4626 }4645 }
46274646
4628 var root_msg: ?*Module.ErrorMsg = null;4647 var root_msg: ?*Module.ErrorMsg = null;
...@@ -4708,7 +4727,7 @@ fn validateStructInit(...@@ -4708,7 +4727,7 @@ fn validateStructInit(
4708 continue;4727 continue;
4709 }4728 }
47104729
4711 const field_ptr_air_ref = sema.inst_map.get(field_ptr).?;4730 const field_ptr_ref = sema.inst_map.get(field_ptr).?;
47124731
4713 //std.debug.print("validateStructInit (field_ptr_air_inst=%{d}):\n", .{4732 //std.debug.print("validateStructInit (field_ptr_air_inst=%{d}):\n", .{
4714 // field_ptr_air_inst,4733 // field_ptr_air_inst,
...@@ -4738,7 +4757,7 @@ fn validateStructInit(...@@ -4738,7 +4757,7 @@ fn validateStructInit(
4738 var block_index = block.instructions.items.len - 1;4757 var block_index = block.instructions.items.len - 1;
4739 while (block_index > 0) : (block_index -= 1) {4758 while (block_index > 0) : (block_index -= 1) {
4740 const store_inst = block.instructions.items[block_index];4759 const store_inst = block.instructions.items[block_index];
4741 if (Air.indexToRef(store_inst) == field_ptr_air_ref) {4760 if (Air.indexToRef(store_inst) == field_ptr_ref) {
4742 struct_is_comptime = false;4761 struct_is_comptime = false;
4743 continue :field;4762 continue :field;
4744 }4763 }
...@@ -4747,26 +4766,19 @@ fn validateStructInit(...@@ -4747,26 +4766,19 @@ fn validateStructInit(
4747 else => continue,4766 else => continue,
4748 }4767 }
4749 const bin_op = air_datas[store_inst].bin_op;4768 const bin_op = air_datas[store_inst].bin_op;
4750 var lhs = bin_op.lhs;4769 var ptr_ref = bin_op.lhs;
4751 {4770 if (Air.refToIndex(ptr_ref)) |ptr_inst| if (air_tags[ptr_inst] == .bitcast) {
4752 const lhs_index = Air.refToIndex(lhs) orelse continue;4771 ptr_ref = air_datas[ptr_inst].ty_op.operand;
4753 if (air_tags[lhs_index] == .bitcast) {4772 };
4754 lhs = air_datas[lhs_index].ty_op.operand;4773 if (ptr_ref != field_ptr_ref) continue;
4755 block_index -= 1;4774 first_block_index = @min(if (Air.refToIndex(field_ptr_ref)) |field_ptr_inst|
4756 }4775 std.mem.lastIndexOfScalar(
4757 }4776 Air.Inst.Index,
4758 if (lhs != field_ptr_air_ref) continue;4777 block.instructions.items[0..block_index],
4759 while (block_index > 0) : (block_index -= 1) {4778 field_ptr_inst,
4760 const block_inst = block.instructions.items[block_index - 1];4779 ).?
4761 if (air_tags[block_inst] != .dbg_stmt) break;4780 else
4762 }4781 block_index, first_block_index);
4763 if (block_index > 0 and
4764 field_ptr_air_ref == Air.indexToRef(block.instructions.items[block_index - 1]))
4765 {
4766 first_block_index = @min(first_block_index, block_index - 1);
4767 } else {
4768 first_block_index = @min(first_block_index, block_index);
4769 }
4770 if (try sema.resolveMaybeUndefValAllowVariablesMaybeRuntime(bin_op.rhs, &make_runtime)) |val| {4782 if (try sema.resolveMaybeUndefValAllowVariablesMaybeRuntime(bin_op.rhs, &make_runtime)) |val| {
4771 field_values[i] = val.toIntern();4783 field_values[i] = val.toIntern();
4772 } else if (require_comptime) {4784 } else if (require_comptime) {
...@@ -4822,8 +4834,40 @@ fn validateStructInit(...@@ -4822,8 +4834,40 @@ fn validateStructInit(
4822 if (struct_is_comptime) {4834 if (struct_is_comptime) {
4823 // Our task is to delete all the `field_ptr` and `store` instructions, and insert4835 // Our task is to delete all the `field_ptr` and `store` instructions, and insert
4824 // instead a single `store` to the struct_ptr with a comptime struct value.4836 // instead a single `store` to the struct_ptr with a comptime struct value.
4837 var init_index: usize = 0;
4838 var field_ptr_ref = Air.Inst.Ref.none;
4839 var block_index = first_block_index;
4840 for (block.instructions.items[first_block_index..]) |cur_inst| {
4841 while (field_ptr_ref == .none and init_index < instrs.len) : (init_index += 1) {
4842 const field_ty = struct_ty.structFieldType(field_indices[init_index], mod);
4843 if (try field_ty.onePossibleValue(mod)) |_| continue;
4844 field_ptr_ref = sema.inst_map.get(instrs[init_index]).?;
4845 }
4846 switch (air_tags[cur_inst]) {
4847 .struct_field_ptr,
4848 .struct_field_ptr_index_0,
4849 .struct_field_ptr_index_1,
4850 .struct_field_ptr_index_2,
4851 .struct_field_ptr_index_3,
4852 => if (Air.indexToRef(cur_inst) == field_ptr_ref) continue,
4853 .bitcast => if (air_datas[cur_inst].ty_op.operand == field_ptr_ref) continue,
4854 .store, .store_safe => {
4855 var ptr_ref = air_datas[cur_inst].bin_op.lhs;
4856 if (Air.refToIndex(ptr_ref)) |ptr_inst| if (air_tags[ptr_inst] == .bitcast) {
4857 ptr_ref = air_datas[ptr_inst].ty_op.operand;
4858 };
4859 if (ptr_ref == field_ptr_ref) {
4860 field_ptr_ref = .none;
4861 continue;
4862 }
4863 },
4864 else => {},
4865 }
4866 block.instructions.items[block_index] = cur_inst;
4867 block_index += 1;
4868 }
4869 block.instructions.shrinkRetainingCapacity(block_index);
48254870
4826 block.instructions.shrinkRetainingCapacity(first_block_index);
4827 var struct_val = try mod.intern(.{ .aggregate = .{4871 var struct_val = try mod.intern(.{ .aggregate = .{
4828 .ty = struct_ty.toIntern(),4872 .ty = struct_ty.toIntern(),
4829 .storage = .{ .elems = field_values },4873 .storage = .{ .elems = field_values },
...@@ -4950,7 +4994,7 @@ fn zirValidateArrayInit(...@@ -4950,7 +4994,7 @@ fn zirValidateArrayInit(
4950 }4994 }
4951 }4995 }
49524996
4953 const elem_ptr_air_ref = sema.inst_map.get(elem_ptr).?;4997 const elem_ptr_ref = sema.inst_map.get(elem_ptr).?;
49544998
4955 // We expect to see something like this in the current block AIR:4999 // We expect to see something like this in the current block AIR:
4956 // %a = elem_ptr(...)5000 // %a = elem_ptr(...)
...@@ -4975,7 +5019,7 @@ fn zirValidateArrayInit(...@@ -4975,7 +5019,7 @@ fn zirValidateArrayInit(
4975 var block_index = block.instructions.items.len - 1;5019 var block_index = block.instructions.items.len - 1;
4976 while (block_index > 0) : (block_index -= 1) {5020 while (block_index > 0) : (block_index -= 1) {
4977 const store_inst = block.instructions.items[block_index];5021 const store_inst = block.instructions.items[block_index];
4978 if (Air.indexToRef(store_inst) == elem_ptr_air_ref) {5022 if (Air.indexToRef(store_inst) == elem_ptr_ref) {
4979 array_is_comptime = false;5023 array_is_comptime = false;
4980 continue :outer;5024 continue :outer;
4981 }5025 }
...@@ -4984,26 +5028,19 @@ fn zirValidateArrayInit(...@@ -4984,26 +5028,19 @@ fn zirValidateArrayInit(
4984 else => continue,5028 else => continue,
4985 }5029 }
4986 const bin_op = air_datas[store_inst].bin_op;5030 const bin_op = air_datas[store_inst].bin_op;
4987 var lhs = bin_op.lhs;5031 var ptr_ref = bin_op.lhs;
4988 {5032 if (Air.refToIndex(ptr_ref)) |ptr_inst| if (air_tags[ptr_inst] == .bitcast) {
4989 const lhs_index = Air.refToIndex(lhs) orelse continue;5033 ptr_ref = air_datas[ptr_inst].ty_op.operand;
4990 if (air_tags[lhs_index] == .bitcast) {5034 };
4991 lhs = air_datas[lhs_index].ty_op.operand;5035 if (ptr_ref != elem_ptr_ref) continue;
4992 block_index -= 1;5036 first_block_index = @min(if (Air.refToIndex(elem_ptr_ref)) |elem_ptr_inst|
4993 }5037 std.mem.lastIndexOfScalar(
4994 }5038 Air.Inst.Index,
4995 if (lhs != elem_ptr_air_ref) continue;5039 block.instructions.items[0..block_index],
4996 while (block_index > 0) : (block_index -= 1) {5040 elem_ptr_inst,
4997 const block_inst = block.instructions.items[block_index - 1];5041 ).?
4998 if (air_tags[block_inst] != .dbg_stmt) break;5042 else
4999 }5043 block_index, first_block_index);
5000 if (block_index > 0 and
5001 elem_ptr_air_ref == Air.indexToRef(block.instructions.items[block_index - 1]))
5002 {
5003 first_block_index = @min(first_block_index, block_index - 1);
5004 } else {
5005 first_block_index = @min(first_block_index, block_index);
5006 }
5007 if (try sema.resolveMaybeUndefValAllowVariablesMaybeRuntime(bin_op.rhs, &make_runtime)) |val| {5044 if (try sema.resolveMaybeUndefValAllowVariablesMaybeRuntime(bin_op.rhs, &make_runtime)) |val| {
5008 element_vals[i] = val.toIntern();5045 element_vals[i] = val.toIntern();
5009 } else {5046 } else {
...@@ -5028,7 +5065,33 @@ fn zirValidateArrayInit(...@@ -5028,7 +5065,33 @@ fn zirValidateArrayInit(
50285065
5029 // Our task is to delete all the `elem_ptr` and `store` instructions, and insert5066 // Our task is to delete all the `elem_ptr` and `store` instructions, and insert
5030 // instead a single `store` to the array_ptr with a comptime struct value.5067 // instead a single `store` to the array_ptr with a comptime struct value.
5031 block.instructions.shrinkRetainingCapacity(first_block_index);5068 var elem_index: usize = 0;
5069 var elem_ptr_ref = Air.Inst.Ref.none;
5070 var block_index = first_block_index;
5071 for (block.instructions.items[first_block_index..]) |cur_inst| {
5072 while (elem_ptr_ref == .none and elem_index < instrs.len) : (elem_index += 1) {
5073 if (array_ty.isTuple(mod) and array_ty.structFieldIsComptime(elem_index, mod)) continue;
5074 elem_ptr_ref = sema.inst_map.get(instrs[elem_index]).?;
5075 }
5076 switch (air_tags[cur_inst]) {
5077 .ptr_elem_ptr => if (Air.indexToRef(cur_inst) == elem_ptr_ref) continue,
5078 .bitcast => if (air_datas[cur_inst].ty_op.operand == elem_ptr_ref) continue,
5079 .store, .store_safe => {
5080 var ptr_ref = air_datas[cur_inst].bin_op.lhs;
5081 if (Air.refToIndex(ptr_ref)) |ptr_inst| if (air_tags[ptr_inst] == .bitcast) {
5082 ptr_ref = air_datas[ptr_inst].ty_op.operand;
5083 };
5084 if (ptr_ref == elem_ptr_ref) {
5085 elem_ptr_ref = .none;
5086 continue;
5087 }
5088 },
5089 else => {},
5090 }
5091 block.instructions.items[block_index] = cur_inst;
5092 block_index += 1;
5093 }
5094 block.instructions.shrinkRetainingCapacity(block_index);
50325095
5033 var array_val = try mod.intern(.{ .aggregate = .{5096 var array_val = try mod.intern(.{ .aggregate = .{
5034 .ty = array_ty.toIntern(),5097 .ty = array_ty.toIntern(),
test/behavior/array.zig+24
...@@ -775,3 +775,27 @@ test "array init with no result pointer sets field result types" {...@@ -775,3 +775,27 @@ test "array init with no result pointer sets field result types" {
775775
776 try expect(y == x);776 try expect(y == x);
777}777}
778
779test "runtime side-effects in comptime-known array init" {
780 var side_effects: u4 = 0;
781 const init = [4]u4{
782 blk: {
783 side_effects += 1;
784 break :blk 1;
785 },
786 blk: {
787 side_effects += 2;
788 break :blk 2;
789 },
790 blk: {
791 side_effects += 4;
792 break :blk 4;
793 },
794 blk: {
795 side_effects += 8;
796 break :blk 8;
797 },
798 };
799 try expectEqual([4]u4{ 1, 2, 4, 8 }, init);
800 try expectEqual(@as(u4, std.math.maxInt(u4)), side_effects);
801}
test/behavior/struct.zig+25
...@@ -1738,3 +1738,28 @@ test "struct init with no result pointer sets field result types" {...@@ -1738,3 +1738,28 @@ test "struct init with no result pointer sets field result types" {
17381738
1739 try expect(y == x);1739 try expect(y == x);
1740}1740}
1741
1742test "runtime side-effects in comptime-known struct init" {
1743 var side_effects: u4 = 0;
1744 const S = struct { a: u4, b: u4, c: u4, d: u4 };
1745 const init = S{
1746 .d = blk: {
1747 side_effects += 8;
1748 break :blk 8;
1749 },
1750 .c = blk: {
1751 side_effects += 4;
1752 break :blk 4;
1753 },
1754 .b = blk: {
1755 side_effects += 2;
1756 break :blk 2;
1757 },
1758 .a = blk: {
1759 side_effects += 1;
1760 break :blk 1;
1761 },
1762 };
1763 try expectEqual(S{ .a = 1, .b = 2, .c = 4, .d = 8 }, init);
1764 try expectEqual(@as(u4, std.math.maxInt(u4)), side_effects);
1765}
tools/lldb_pretty_printers.py+5-11
...@@ -347,15 +347,9 @@ class TagAndPayload_SynthProvider:...@@ -347,15 +347,9 @@ class TagAndPayload_SynthProvider:
347 except: return -1347 except: return -1
348 def get_child_at_index(self, index): return (self.tag, self.payload)[index] if index in range(2) else None348 def get_child_at_index(self, index): return (self.tag, self.payload)[index] if index in range(2) else None
349349
350def Zir_Inst__Zir_Inst_Ref_SummaryProvider(value, _=None):350def InstRef_SummaryProvider(value, _=None):
351 members = value.type.enum_members351 return value if any(value.unsigned == member.unsigned for member in value.type.enum_members) else (
352 # ignore .var_args_param_type and .none352 'InternPool.Index(%d)' % value.unsigned if value.unsigned < 0x80000000 else 'instructions[%d]' % (value.unsigned - 0x80000000))
353 return value if any(value.unsigned == member.unsigned for member in members) else 'instructions[%d]' % (value.unsigned + 2 - len(members))
354
355def Air_Inst__Air_Inst_Ref_SummaryProvider(value, _=None):
356 members = value.type.enum_members
357 # ignore .var_args_param_type and .none
358 return value if any(value.unsigned == member.unsigned for member in members) else 'instructions[%d]' % (value.unsigned + 2 - len(members))
359353
360class Module_Decl__Module_Decl_Index_SynthProvider:354class Module_Decl__Module_Decl_Index_SynthProvider:
361 def __init__(self, value, _=None): self.value = value355 def __init__(self, value, _=None): self.value = value
...@@ -700,9 +694,9 @@ def __lldb_init_module(debugger, _=None):...@@ -700,9 +694,9 @@ def __lldb_init_module(debugger, _=None):
700 add(debugger, category='zig.stage2', type='Zir.Inst', identifier='TagAndPayload', synth=True, inline_children=True, summary=True)694 add(debugger, category='zig.stage2', type='Zir.Inst', identifier='TagAndPayload', synth=True, inline_children=True, summary=True)
701 add(debugger, category='zig.stage2', regex=True, type=MultiArrayList_Entry('Zir\\.Inst'), identifier='TagAndPayload', synth=True, inline_children=True, summary=True)695 add(debugger, category='zig.stage2', regex=True, type=MultiArrayList_Entry('Zir\\.Inst'), identifier='TagAndPayload', synth=True, inline_children=True, summary=True)
702 add(debugger, category='zig.stage2', regex=True, type='^Zir\\.Inst\\.Data\\.Data__struct_[1-9][0-9]*$', inline_children=True, summary=True)696 add(debugger, category='zig.stage2', regex=True, type='^Zir\\.Inst\\.Data\\.Data__struct_[1-9][0-9]*$', inline_children=True, summary=True)
703 add(debugger, category='zig.stage2', type='Zir.Inst::Zir.Inst.Ref', summary=True)697 add(debugger, category='zig.stage2', type='Zir.Inst::Zir.Inst.Ref', identifier='InstRef', summary=True)
704 add(debugger, category='zig.stage2', type='Air.Inst', identifier='TagAndPayload', synth=True, inline_children=True, summary=True)698 add(debugger, category='zig.stage2', type='Air.Inst', identifier='TagAndPayload', synth=True, inline_children=True, summary=True)
705 add(debugger, category='zig.stage2', type='Air.Inst::Air.Inst.Ref', summary=True)699 add(debugger, category='zig.stage2', type='Air.Inst::Air.Inst.Ref', identifier='InstRef', summary=True)
706 add(debugger, category='zig.stage2', regex=True, type=MultiArrayList_Entry('Air\\.Inst'), identifier='TagAndPayload', synth=True, inline_children=True, summary=True)700 add(debugger, category='zig.stage2', regex=True, type=MultiArrayList_Entry('Air\\.Inst'), identifier='TagAndPayload', synth=True, inline_children=True, summary=True)
707 add(debugger, category='zig.stage2', regex=True, type='^Air\\.Inst\\.Data\\.Data__struct_[1-9][0-9]*$', inline_children=True, summary=True)701 add(debugger, category='zig.stage2', regex=True, type='^Air\\.Inst\\.Data\\.Data__struct_[1-9][0-9]*$', inline_children=True, summary=True)
708 add(debugger, category='zig.stage2', type='Module.Decl::Module.Decl.Index', synth=True)702 add(debugger, category='zig.stage2', type='Module.Decl::Module.Decl.Index', synth=True)