authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-30 13:54:22-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:47:57-07:00
log90a877f462fce8bee69ad366aac66805a7c00571
treefd4271ea498f27ec12c5f9e10fd70cdd25de9279
parent6b81546454f925807d2298a127458741be7239e9

InternPool: pass by const pointer

The Zig language allows the compiler to make this optimization automatically. We should definitely make the compiler do that, and revert this commit. However, that will not happen in this branch, and I want to continue to explore achieving performance parity with merge-base. So, this commit changes all InternPool parameters to be passed by const pointer rather than by value. I measured a 1.03x ± 0.03 speedup vs the previous commit compiling the (set of passing) behavior tests. Against merge-base, this commit is 1.17x ± 0.04 slower, which is an improvement from the previous measurement of 1.22x ± 0.02. Related issue: #13510 Related issue: #14129 Related issue: #15688

17 files changed, 94 insertions(+), 94 deletions(-)

src/Air.zig+4-4
...@@ -1182,7 +1182,7 @@ pub fn getMainBody(air: Air) []const Air.Inst.Index {...@@ -1182,7 +1182,7 @@ pub fn getMainBody(air: Air) []const Air.Inst.Index {
1182 return air.extra[extra.end..][0..extra.data.body_len];1182 return air.extra[extra.end..][0..extra.data.body_len];
1183}1183}
11841184
1185pub fn typeOf(air: Air, inst: Air.Inst.Ref, ip: InternPool) Type {1185pub fn typeOf(air: Air, inst: Air.Inst.Ref, ip: *const InternPool) Type {
1186 const ref_int = @enumToInt(inst);1186 const ref_int = @enumToInt(inst);
1187 if (ref_int < InternPool.static_keys.len) {1187 if (ref_int < InternPool.static_keys.len) {
1188 return InternPool.static_keys[ref_int].typeOf().toType();1188 return InternPool.static_keys[ref_int].typeOf().toType();
...@@ -1190,7 +1190,7 @@ pub fn typeOf(air: Air, inst: Air.Inst.Ref, ip: InternPool) Type {...@@ -1190,7 +1190,7 @@ pub fn typeOf(air: Air, inst: Air.Inst.Ref, ip: InternPool) Type {
1190 return air.typeOfIndex(ref_int - ref_start_index, ip);1190 return air.typeOfIndex(ref_int - ref_start_index, ip);
1191}1191}
11921192
1193pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: InternPool) Type {1193pub fn typeOfIndex(air: Air, inst: Air.Inst.Index, ip: *const InternPool) Type {
1194 const datas = air.instructions.items(.data);1194 const datas = air.instructions.items(.data);
1195 switch (air.instructions.items(.tag)[inst]) {1195 switch (air.instructions.items(.tag)[inst]) {
1196 .add,1196 .add,
...@@ -1520,7 +1520,7 @@ pub fn value(air: Air, inst: Inst.Ref, mod: *Module) !?Value {...@@ -1520,7 +1520,7 @@ pub fn value(air: Air, inst: Inst.Ref, mod: *Module) !?Value {
1520 const air_datas = air.instructions.items(.data);1520 const air_datas = air.instructions.items(.data);
1521 switch (air.instructions.items(.tag)[inst_index]) {1521 switch (air.instructions.items(.tag)[inst_index]) {
1522 .interned => return air_datas[inst_index].interned.toValue(),1522 .interned => return air_datas[inst_index].interned.toValue(),
1523 else => return air.typeOfIndex(inst_index, mod.intern_pool).onePossibleValue(mod),1523 else => return air.typeOfIndex(inst_index, &mod.intern_pool).onePossibleValue(mod),
1524 }1524 }
1525}1525}
15261526
...@@ -1537,7 +1537,7 @@ pub fn nullTerminatedString(air: Air, index: usize) [:0]const u8 {...@@ -1537,7 +1537,7 @@ pub fn nullTerminatedString(air: Air, index: usize) [:0]const u8 {
1537/// because it can cause side effects. If an instruction does not need to be1537/// because it can cause side effects. If an instruction does not need to be
1538/// lowered, and Liveness determines its result is unused, backends should1538/// lowered, and Liveness determines its result is unused, backends should
1539/// avoid lowering it.1539/// avoid lowering it.
1540pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: InternPool) bool {1540pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
1541 const data = air.instructions.items(.data)[inst];1541 const data = air.instructions.items(.data)[inst];
1542 return switch (air.instructions.items(.tag)[inst]) {1542 return switch (air.instructions.items(.tag)[inst]) {
1543 .arg,1543 .arg,
src/InternPool.zig+42-42
...@@ -2992,7 +2992,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {...@@ -2992,7 +2992,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
2992 };2992 };
2993}2993}
29942994
2995fn indexToKeyFuncType(ip: InternPool, data: u32) Key.FuncType {2995fn indexToKeyFuncType(ip: *const InternPool, data: u32) Key.FuncType {
2996 const type_function = ip.extraDataTrail(TypeFunction, data);2996 const type_function = ip.extraDataTrail(TypeFunction, data);
2997 const param_types = @ptrCast(2997 const param_types = @ptrCast(
2998 []Index,2998 []Index,
...@@ -3015,7 +3015,7 @@ fn indexToKeyFuncType(ip: InternPool, data: u32) Key.FuncType {...@@ -3015,7 +3015,7 @@ fn indexToKeyFuncType(ip: InternPool, data: u32) Key.FuncType {
3015 };3015 };
3016}3016}
30173017
3018fn indexToKeyEnum(ip: InternPool, data: u32, tag_mode: Key.EnumType.TagMode) Key {3018fn indexToKeyEnum(ip: *const InternPool, data: u32, tag_mode: Key.EnumType.TagMode) Key {
3019 const enum_explicit = ip.extraDataTrail(EnumExplicit, data);3019 const enum_explicit = ip.extraDataTrail(EnumExplicit, data);
3020 const names = @ptrCast(3020 const names = @ptrCast(
3021 []const NullTerminatedString,3021 []const NullTerminatedString,
...@@ -3038,7 +3038,7 @@ fn indexToKeyEnum(ip: InternPool, data: u32, tag_mode: Key.EnumType.TagMode) Key...@@ -3038,7 +3038,7 @@ fn indexToKeyEnum(ip: InternPool, data: u32, tag_mode: Key.EnumType.TagMode) Key
3038 } };3038 } };
3039}3039}
30403040
3041fn indexToKeyBigInt(ip: InternPool, limb_index: u32, positive: bool) Key {3041fn indexToKeyBigInt(ip: *const InternPool, limb_index: u32, positive: bool) Key {
3042 const int_info = ip.limbData(Int, limb_index);3042 const int_info = ip.limbData(Int, limb_index);
3043 return .{ .int = .{3043 return .{ .int = .{
3044 .ty = int_info.ty,3044 .ty = int_info.ty,
...@@ -4351,7 +4351,7 @@ fn addLimbsAssumeCapacity(ip: *InternPool, limbs: []const Limb) void {...@@ -4351,7 +4351,7 @@ fn addLimbsAssumeCapacity(ip: *InternPool, limbs: []const Limb) void {
4351 }4351 }
4352}4352}
43534353
4354fn extraDataTrail(ip: InternPool, comptime T: type, index: usize) struct { data: T, end: usize } {4354fn extraDataTrail(ip: *const InternPool, comptime T: type, index: usize) struct { data: T, end: usize } {
4355 var result: T = undefined;4355 var result: T = undefined;
4356 const fields = @typeInfo(T).Struct.fields;4356 const fields = @typeInfo(T).Struct.fields;
4357 inline for (fields, 0..) |field, i| {4357 inline for (fields, 0..) |field, i| {
...@@ -4384,12 +4384,12 @@ fn extraDataTrail(ip: InternPool, comptime T: type, index: usize) struct { data:...@@ -4384,12 +4384,12 @@ fn extraDataTrail(ip: InternPool, comptime T: type, index: usize) struct { data:
4384 };4384 };
4385}4385}
43864386
4387fn extraData(ip: InternPool, comptime T: type, index: usize) T {4387fn extraData(ip: *const InternPool, comptime T: type, index: usize) T {
4388 return extraDataTrail(ip, T, index).data;4388 return extraDataTrail(ip, T, index).data;
4389}4389}
43904390
4391/// Asserts the struct has 32-bit fields and the number of fields is evenly divisible by 2.4391/// Asserts the struct has 32-bit fields and the number of fields is evenly divisible by 2.
4392fn limbData(ip: InternPool, comptime T: type, index: usize) T {4392fn limbData(ip: *const InternPool, comptime T: type, index: usize) T {
4393 switch (@sizeOf(Limb)) {4393 switch (@sizeOf(Limb)) {
4394 @sizeOf(u32) => return extraData(ip, T, index),4394 @sizeOf(u32) => return extraData(ip, T, index),
4395 @sizeOf(u64) => {},4395 @sizeOf(u64) => {},
...@@ -4413,7 +4413,7 @@ fn limbData(ip: InternPool, comptime T: type, index: usize) T {...@@ -4413,7 +4413,7 @@ fn limbData(ip: InternPool, comptime T: type, index: usize) T {
4413}4413}
44144414
4415/// This function returns the Limb slice that is trailing data after a payload.4415/// This function returns the Limb slice that is trailing data after a payload.
4416fn limbSlice(ip: InternPool, comptime S: type, limb_index: u32, len: u32) []const Limb {4416fn limbSlice(ip: *const InternPool, comptime S: type, limb_index: u32, len: u32) []const Limb {
4417 const field_count = @typeInfo(S).Struct.fields.len;4417 const field_count = @typeInfo(S).Struct.fields.len;
4418 switch (@sizeOf(Limb)) {4418 switch (@sizeOf(Limb)) {
4419 @sizeOf(u32) => {4419 @sizeOf(u32) => {
...@@ -4433,7 +4433,7 @@ const LimbsAsIndexes = struct {...@@ -4433,7 +4433,7 @@ const LimbsAsIndexes = struct {
4433 len: u32,4433 len: u32,
4434};4434};
44354435
4436fn limbsSliceToIndex(ip: InternPool, limbs: []const Limb) LimbsAsIndexes {4436fn limbsSliceToIndex(ip: *const InternPool, limbs: []const Limb) LimbsAsIndexes {
4437 const host_slice = switch (@sizeOf(Limb)) {4437 const host_slice = switch (@sizeOf(Limb)) {
4438 @sizeOf(u32) => ip.extra.items,4438 @sizeOf(u32) => ip.extra.items,
4439 @sizeOf(u64) => ip.limbs.items,4439 @sizeOf(u64) => ip.limbs.items,
...@@ -4447,7 +4447,7 @@ fn limbsSliceToIndex(ip: InternPool, limbs: []const Limb) LimbsAsIndexes {...@@ -4447,7 +4447,7 @@ fn limbsSliceToIndex(ip: InternPool, limbs: []const Limb) LimbsAsIndexes {
4447}4447}
44484448
4449/// This function converts Limb array indexes to a primitive slice type.4449/// This function converts Limb array indexes to a primitive slice type.
4450fn limbsIndexToSlice(ip: InternPool, limbs: LimbsAsIndexes) []const Limb {4450fn limbsIndexToSlice(ip: *const InternPool, limbs: LimbsAsIndexes) []const Limb {
4451 return switch (@sizeOf(Limb)) {4451 return switch (@sizeOf(Limb)) {
4452 @sizeOf(u32) => ip.extra.items[limbs.start..][0..limbs.len],4452 @sizeOf(u32) => ip.extra.items[limbs.start..][0..limbs.len],
4453 @sizeOf(u64) => ip.limbs.items[limbs.start..][0..limbs.len],4453 @sizeOf(u64) => ip.limbs.items[limbs.start..][0..limbs.len],
...@@ -4485,7 +4485,7 @@ test "basic usage" {...@@ -4485,7 +4485,7 @@ test "basic usage" {
4485 try std.testing.expect(another_array_i32 == array_i32);4485 try std.testing.expect(another_array_i32 == array_i32);
4486}4486}
44874487
4488pub fn childType(ip: InternPool, i: Index) Index {4488pub fn childType(ip: *const InternPool, i: Index) Index {
4489 return switch (ip.indexToKey(i)) {4489 return switch (ip.indexToKey(i)) {
4490 .ptr_type => |ptr_type| ptr_type.elem_type,4490 .ptr_type => |ptr_type| ptr_type.elem_type,
4491 .vector_type => |vector_type| vector_type.child,4491 .vector_type => |vector_type| vector_type.child,
...@@ -4496,7 +4496,7 @@ pub fn childType(ip: InternPool, i: Index) Index {...@@ -4496,7 +4496,7 @@ pub fn childType(ip: InternPool, i: Index) Index {
4496}4496}
44974497
4498/// Given a slice type, returns the type of the ptr field.4498/// Given a slice type, returns the type of the ptr field.
4499pub fn slicePtrType(ip: InternPool, i: Index) Index {4499pub fn slicePtrType(ip: *const InternPool, i: Index) Index {
4500 switch (i) {4500 switch (i) {
4501 .slice_const_u8_type => return .manyptr_const_u8_type,4501 .slice_const_u8_type => return .manyptr_const_u8_type,
4502 .slice_const_u8_sentinel_0_type => return .manyptr_const_u8_sentinel_0_type,4502 .slice_const_u8_sentinel_0_type => return .manyptr_const_u8_sentinel_0_type,
...@@ -4510,7 +4510,7 @@ pub fn slicePtrType(ip: InternPool, i: Index) Index {...@@ -4510,7 +4510,7 @@ pub fn slicePtrType(ip: InternPool, i: Index) Index {
4510}4510}
45114511
4512/// Given a slice value, returns the value of the ptr field.4512/// Given a slice value, returns the value of the ptr field.
4513pub fn slicePtr(ip: InternPool, i: Index) Index {4513pub fn slicePtr(ip: *const InternPool, i: Index) Index {
4514 const item = ip.items.get(@enumToInt(i));4514 const item = ip.items.get(@enumToInt(i));
4515 switch (item.tag) {4515 switch (item.tag) {
4516 .ptr_slice => return ip.extraData(PtrSlice, item.data).ptr,4516 .ptr_slice => return ip.extraData(PtrSlice, item.data).ptr,
...@@ -4519,7 +4519,7 @@ pub fn slicePtr(ip: InternPool, i: Index) Index {...@@ -4519,7 +4519,7 @@ pub fn slicePtr(ip: InternPool, i: Index) Index {
4519}4519}
45204520
4521/// Given a slice value, returns the value of the len field.4521/// Given a slice value, returns the value of the len field.
4522pub fn sliceLen(ip: InternPool, i: Index) Index {4522pub fn sliceLen(ip: *const InternPool, i: Index) Index {
4523 const item = ip.items.get(@enumToInt(i));4523 const item = ip.items.get(@enumToInt(i));
4524 switch (item.tag) {4524 switch (item.tag) {
4525 .ptr_slice => return ip.extraData(PtrSlice, item.data).len,4525 .ptr_slice => return ip.extraData(PtrSlice, item.data).len,
...@@ -4702,7 +4702,7 @@ pub fn getCoercedInts(ip: *InternPool, gpa: Allocator, int: Key.Int, new_ty: Ind...@@ -4702,7 +4702,7 @@ pub fn getCoercedInts(ip: *InternPool, gpa: Allocator, int: Key.Int, new_ty: Ind
4702 } });4702 } });
4703}4703}
47044704
4705pub fn indexToStructType(ip: InternPool, val: Index) Module.Struct.OptionalIndex {4705pub fn indexToStructType(ip: *const InternPool, val: Index) Module.Struct.OptionalIndex {
4706 assert(val != .none);4706 assert(val != .none);
4707 const tags = ip.items.items(.tag);4707 const tags = ip.items.items(.tag);
4708 if (tags[@enumToInt(val)] != .type_struct) return .none;4708 if (tags[@enumToInt(val)] != .type_struct) return .none;
...@@ -4710,7 +4710,7 @@ pub fn indexToStructType(ip: InternPool, val: Index) Module.Struct.OptionalIndex...@@ -4710,7 +4710,7 @@ pub fn indexToStructType(ip: InternPool, val: Index) Module.Struct.OptionalIndex
4710 return @intToEnum(Module.Struct.Index, datas[@enumToInt(val)]).toOptional();4710 return @intToEnum(Module.Struct.Index, datas[@enumToInt(val)]).toOptional();
4711}4711}
47124712
4713pub fn indexToUnionType(ip: InternPool, val: Index) Module.Union.OptionalIndex {4713pub fn indexToUnionType(ip: *const InternPool, val: Index) Module.Union.OptionalIndex {
4714 assert(val != .none);4714 assert(val != .none);
4715 const tags = ip.items.items(.tag);4715 const tags = ip.items.items(.tag);
4716 switch (tags[@enumToInt(val)]) {4716 switch (tags[@enumToInt(val)]) {
...@@ -4721,7 +4721,7 @@ pub fn indexToUnionType(ip: InternPool, val: Index) Module.Union.OptionalIndex {...@@ -4721,7 +4721,7 @@ pub fn indexToUnionType(ip: InternPool, val: Index) Module.Union.OptionalIndex {
4721 return @intToEnum(Module.Union.Index, datas[@enumToInt(val)]).toOptional();4721 return @intToEnum(Module.Union.Index, datas[@enumToInt(val)]).toOptional();
4722}4722}
47234723
4724pub fn indexToFuncType(ip: InternPool, val: Index) ?Key.FuncType {4724pub fn indexToFuncType(ip: *const InternPool, val: Index) ?Key.FuncType {
4725 assert(val != .none);4725 assert(val != .none);
4726 const tags = ip.items.items(.tag);4726 const tags = ip.items.items(.tag);
4727 const datas = ip.items.items(.data);4727 const datas = ip.items.items(.data);
...@@ -4731,7 +4731,7 @@ pub fn indexToFuncType(ip: InternPool, val: Index) ?Key.FuncType {...@@ -4731,7 +4731,7 @@ pub fn indexToFuncType(ip: InternPool, val: Index) ?Key.FuncType {
4731 }4731 }
4732}4732}
47334733
4734pub fn indexToFunc(ip: InternPool, val: Index) Module.Fn.OptionalIndex {4734pub fn indexToFunc(ip: *const InternPool, val: Index) Module.Fn.OptionalIndex {
4735 assert(val != .none);4735 assert(val != .none);
4736 const tags = ip.items.items(.tag);4736 const tags = ip.items.items(.tag);
4737 if (tags[@enumToInt(val)] != .func) return .none;4737 if (tags[@enumToInt(val)] != .func) return .none;
...@@ -4739,7 +4739,7 @@ pub fn indexToFunc(ip: InternPool, val: Index) Module.Fn.OptionalIndex {...@@ -4739,7 +4739,7 @@ pub fn indexToFunc(ip: InternPool, val: Index) Module.Fn.OptionalIndex {
4739 return ip.extraData(Key.Func, datas[@enumToInt(val)]).index.toOptional();4739 return ip.extraData(Key.Func, datas[@enumToInt(val)]).index.toOptional();
4740}4740}
47414741
4742pub fn indexToInferredErrorSetType(ip: InternPool, val: Index) Module.Fn.InferredErrorSet.OptionalIndex {4742pub fn indexToInferredErrorSetType(ip: *const InternPool, val: Index) Module.Fn.InferredErrorSet.OptionalIndex {
4743 assert(val != .none);4743 assert(val != .none);
4744 const tags = ip.items.items(.tag);4744 const tags = ip.items.items(.tag);
4745 if (tags[@enumToInt(val)] != .type_inferred_error_set) return .none;4745 if (tags[@enumToInt(val)] != .type_inferred_error_set) return .none;
...@@ -4748,7 +4748,7 @@ pub fn indexToInferredErrorSetType(ip: InternPool, val: Index) Module.Fn.Inferre...@@ -4748,7 +4748,7 @@ pub fn indexToInferredErrorSetType(ip: InternPool, val: Index) Module.Fn.Inferre
4748}4748}
47494749
4750/// includes .comptime_int_type4750/// includes .comptime_int_type
4751pub fn isIntegerType(ip: InternPool, ty: Index) bool {4751pub fn isIntegerType(ip: *const InternPool, ty: Index) bool {
4752 return switch (ty) {4752 return switch (ty) {
4753 .usize_type,4753 .usize_type,
4754 .isize_type,4754 .isize_type,
...@@ -4769,7 +4769,7 @@ pub fn isIntegerType(ip: InternPool, ty: Index) bool {...@@ -4769,7 +4769,7 @@ pub fn isIntegerType(ip: InternPool, ty: Index) bool {
4769}4769}
47704770
4771/// does not include .enum_literal_type4771/// does not include .enum_literal_type
4772pub fn isEnumType(ip: InternPool, ty: Index) bool {4772pub fn isEnumType(ip: *const InternPool, ty: Index) bool {
4773 return switch (ty) {4773 return switch (ty) {
4774 .atomic_order_type,4774 .atomic_order_type,
4775 .atomic_rmw_op_type,4775 .atomic_rmw_op_type,
...@@ -4783,35 +4783,35 @@ pub fn isEnumType(ip: InternPool, ty: Index) bool {...@@ -4783,35 +4783,35 @@ pub fn isEnumType(ip: InternPool, ty: Index) bool {
4783 };4783 };
4784}4784}
47854785
4786pub fn isFunctionType(ip: InternPool, ty: Index) bool {4786pub fn isFunctionType(ip: *const InternPool, ty: Index) bool {
4787 return ip.indexToKey(ty) == .func_type;4787 return ip.indexToKey(ty) == .func_type;
4788}4788}
47894789
4790pub fn isPointerType(ip: InternPool, ty: Index) bool {4790pub fn isPointerType(ip: *const InternPool, ty: Index) bool {
4791 return ip.indexToKey(ty) == .ptr_type;4791 return ip.indexToKey(ty) == .ptr_type;
4792}4792}
47934793
4794pub fn isOptionalType(ip: InternPool, ty: Index) bool {4794pub fn isOptionalType(ip: *const InternPool, ty: Index) bool {
4795 return ip.indexToKey(ty) == .opt_type;4795 return ip.indexToKey(ty) == .opt_type;
4796}4796}
47974797
4798/// includes .inferred_error_set_type4798/// includes .inferred_error_set_type
4799pub fn isErrorSetType(ip: InternPool, ty: Index) bool {4799pub fn isErrorSetType(ip: *const InternPool, ty: Index) bool {
4800 return ty == .anyerror_type or switch (ip.indexToKey(ty)) {4800 return ty == .anyerror_type or switch (ip.indexToKey(ty)) {
4801 .error_set_type, .inferred_error_set_type => true,4801 .error_set_type, .inferred_error_set_type => true,
4802 else => false,4802 else => false,
4803 };4803 };
4804}4804}
48054805
4806pub fn isInferredErrorSetType(ip: InternPool, ty: Index) bool {4806pub fn isInferredErrorSetType(ip: *const InternPool, ty: Index) bool {
4807 return ip.indexToKey(ty) == .inferred_error_set_type;4807 return ip.indexToKey(ty) == .inferred_error_set_type;
4808}4808}
48094809
4810pub fn isErrorUnionType(ip: InternPool, ty: Index) bool {4810pub fn isErrorUnionType(ip: *const InternPool, ty: Index) bool {
4811 return ip.indexToKey(ty) == .error_union_type;4811 return ip.indexToKey(ty) == .error_union_type;
4812}4812}
48134813
4814pub fn isAggregateType(ip: InternPool, ty: Index) bool {4814pub fn isAggregateType(ip: *const InternPool, ty: Index) bool {
4815 return switch (ip.indexToKey(ty)) {4815 return switch (ip.indexToKey(ty)) {
4816 .array_type, .vector_type, .anon_struct_type, .struct_type => true,4816 .array_type, .vector_type, .anon_struct_type, .struct_type => true,
4817 else => false,4817 else => false,
...@@ -4827,11 +4827,11 @@ pub fn mutateVarInit(ip: *InternPool, index: Index, init_index: Index) void {...@@ -4827,11 +4827,11 @@ pub fn mutateVarInit(ip: *InternPool, index: Index, init_index: Index) void {
4827 ip.extra.items[ip.items.items(.data)[@enumToInt(index)] + field_index] = @enumToInt(init_index);4827 ip.extra.items[ip.items.items(.data)[@enumToInt(index)] + field_index] = @enumToInt(init_index);
4828}4828}
48294829
4830pub fn dump(ip: InternPool) void {4830pub fn dump(ip: *const InternPool) void {
4831 dumpFallible(ip, std.heap.page_allocator) catch return;4831 dumpFallible(ip, std.heap.page_allocator) catch return;
4832}4832}
48334833
4834fn dumpFallible(ip: InternPool, arena: Allocator) anyerror!void {4834fn dumpFallible(ip: *const InternPool, arena: Allocator) anyerror!void {
4835 const items_size = (1 + 4) * ip.items.len;4835 const items_size = (1 + 4) * ip.items.len;
4836 const extra_size = 4 * ip.extra.items.len;4836 const extra_size = 4 * ip.extra.items.len;
4837 const limbs_size = 8 * ip.limbs.items.len;4837 const limbs_size = 8 * ip.limbs.items.len;
...@@ -5023,11 +5023,11 @@ pub fn structPtr(ip: *InternPool, index: Module.Struct.Index) *Module.Struct {...@@ -5023,11 +5023,11 @@ pub fn structPtr(ip: *InternPool, index: Module.Struct.Index) *Module.Struct {
5023 return ip.allocated_structs.at(@enumToInt(index));5023 return ip.allocated_structs.at(@enumToInt(index));
5024}5024}
50255025
5026pub fn structPtrConst(ip: InternPool, index: Module.Struct.Index) *const Module.Struct {5026pub fn structPtrConst(ip: *const InternPool, index: Module.Struct.Index) *const Module.Struct {
5027 return ip.allocated_structs.at(@enumToInt(index));5027 return ip.allocated_structs.at(@enumToInt(index));
5028}5028}
50295029
5030pub fn structPtrUnwrapConst(ip: InternPool, index: Module.Struct.OptionalIndex) ?*const Module.Struct {5030pub fn structPtrUnwrapConst(ip: *const InternPool, index: Module.Struct.OptionalIndex) ?*const Module.Struct {
5031 return structPtrConst(ip, index.unwrap() orelse return null);5031 return structPtrConst(ip, index.unwrap() orelse return null);
5032}5032}
50335033
...@@ -5035,7 +5035,7 @@ pub fn unionPtr(ip: *InternPool, index: Module.Union.Index) *Module.Union {...@@ -5035,7 +5035,7 @@ pub fn unionPtr(ip: *InternPool, index: Module.Union.Index) *Module.Union {
5035 return ip.allocated_unions.at(@enumToInt(index));5035 return ip.allocated_unions.at(@enumToInt(index));
5036}5036}
50375037
5038pub fn unionPtrConst(ip: InternPool, index: Module.Union.Index) *const Module.Union {5038pub fn unionPtrConst(ip: *const InternPool, index: Module.Union.Index) *const Module.Union {
5039 return ip.allocated_unions.at(@enumToInt(index));5039 return ip.allocated_unions.at(@enumToInt(index));
5040}5040}
50415041
...@@ -5043,7 +5043,7 @@ pub fn funcPtr(ip: *InternPool, index: Module.Fn.Index) *Module.Fn {...@@ -5043,7 +5043,7 @@ pub fn funcPtr(ip: *InternPool, index: Module.Fn.Index) *Module.Fn {
5043 return ip.allocated_funcs.at(@enumToInt(index));5043 return ip.allocated_funcs.at(@enumToInt(index));
5044}5044}
50455045
5046pub fn funcPtrConst(ip: InternPool, index: Module.Fn.Index) *const Module.Fn {5046pub fn funcPtrConst(ip: *const InternPool, index: Module.Fn.Index) *const Module.Fn {
5047 return ip.allocated_funcs.at(@enumToInt(index));5047 return ip.allocated_funcs.at(@enumToInt(index));
5048}5048}
50495049
...@@ -5051,7 +5051,7 @@ pub fn inferredErrorSetPtr(ip: *InternPool, index: Module.Fn.InferredErrorSet.In...@@ -5051,7 +5051,7 @@ pub fn inferredErrorSetPtr(ip: *InternPool, index: Module.Fn.InferredErrorSet.In
5051 return ip.allocated_inferred_error_sets.at(@enumToInt(index));5051 return ip.allocated_inferred_error_sets.at(@enumToInt(index));
5052}5052}
50535053
5054pub fn inferredErrorSetPtrConst(ip: InternPool, index: Module.Fn.InferredErrorSet.Index) *const Module.Fn.InferredErrorSet {5054pub fn inferredErrorSetPtrConst(ip: *const InternPool, index: Module.Fn.InferredErrorSet.Index) *const Module.Fn.InferredErrorSet {
5055 return ip.allocated_inferred_error_sets.at(@enumToInt(index));5055 return ip.allocated_inferred_error_sets.at(@enumToInt(index));
5056}5056}
50575057
...@@ -5182,7 +5182,7 @@ pub fn getString(ip: *InternPool, s: []const u8) OptionalNullTerminatedString {...@@ -5182,7 +5182,7 @@ pub fn getString(ip: *InternPool, s: []const u8) OptionalNullTerminatedString {
5182 }5182 }
5183}5183}
51845184
5185pub fn stringToSlice(ip: InternPool, s: NullTerminatedString) [:0]const u8 {5185pub fn stringToSlice(ip: *const InternPool, s: NullTerminatedString) [:0]const u8 {
5186 const string_bytes = ip.string_bytes.items;5186 const string_bytes = ip.string_bytes.items;
5187 const start = @enumToInt(s);5187 const start = @enumToInt(s);
5188 var end: usize = start;5188 var end: usize = start;
...@@ -5190,11 +5190,11 @@ pub fn stringToSlice(ip: InternPool, s: NullTerminatedString) [:0]const u8 {...@@ -5190,11 +5190,11 @@ pub fn stringToSlice(ip: InternPool, s: NullTerminatedString) [:0]const u8 {
5190 return string_bytes[start..end :0];5190 return string_bytes[start..end :0];
5191}5191}
51925192
5193pub fn stringToSliceUnwrap(ip: InternPool, s: OptionalNullTerminatedString) ?[:0]const u8 {5193pub fn stringToSliceUnwrap(ip: *const InternPool, s: OptionalNullTerminatedString) ?[:0]const u8 {
5194 return ip.stringToSlice(s.unwrap() orelse return null);5194 return ip.stringToSlice(s.unwrap() orelse return null);
5195}5195}
51965196
5197pub fn typeOf(ip: InternPool, index: Index) Index {5197pub fn typeOf(ip: *const InternPool, index: Index) Index {
5198 // This optimization of static keys is required so that typeOf can be called5198 // This optimization of static keys is required so that typeOf can be called
5199 // on static keys that haven't been added yet during static key initialization.5199 // on static keys that haven't been added yet during static key initialization.
5200 // An alternative would be to topological sort the static keys, but this would5200 // An alternative would be to topological sort the static keys, but this would
...@@ -5382,12 +5382,12 @@ pub fn typeOf(ip: InternPool, index: Index) Index {...@@ -5382,12 +5382,12 @@ pub fn typeOf(ip: InternPool, index: Index) Index {
5382}5382}
53835383
5384/// Assumes that the enum's field indexes equal its value tags.5384/// Assumes that the enum's field indexes equal its value tags.
5385pub fn toEnum(ip: InternPool, comptime E: type, i: Index) E {5385pub fn toEnum(ip: *const InternPool, comptime E: type, i: Index) E {
5386 const int = ip.indexToKey(i).enum_tag.int;5386 const int = ip.indexToKey(i).enum_tag.int;
5387 return @intToEnum(E, ip.indexToKey(int).int.storage.u64);5387 return @intToEnum(E, ip.indexToKey(int).int.storage.u64);
5388}5388}
53895389
5390pub fn aggregateTypeLen(ip: InternPool, ty: Index) u64 {5390pub fn aggregateTypeLen(ip: *const InternPool, ty: Index) u64 {
5391 return switch (ip.indexToKey(ty)) {5391 return switch (ip.indexToKey(ty)) {
5392 .struct_type => |struct_type| ip.structPtrConst(struct_type.index.unwrap() orelse return 0).fields.count(),5392 .struct_type => |struct_type| ip.structPtrConst(struct_type.index.unwrap() orelse return 0).fields.count(),
5393 .anon_struct_type => |anon_struct_type| anon_struct_type.types.len,5393 .anon_struct_type => |anon_struct_type| anon_struct_type.types.len,
...@@ -5397,7 +5397,7 @@ pub fn aggregateTypeLen(ip: InternPool, ty: Index) u64 {...@@ -5397,7 +5397,7 @@ pub fn aggregateTypeLen(ip: InternPool, ty: Index) u64 {
5397 };5397 };
5398}5398}
53995399
5400pub fn aggregateTypeLenIncludingSentinel(ip: InternPool, ty: Index) u64 {5400pub fn aggregateTypeLenIncludingSentinel(ip: *const InternPool, ty: Index) u64 {
5401 return switch (ip.indexToKey(ty)) {5401 return switch (ip.indexToKey(ty)) {
5402 .struct_type => |struct_type| ip.structPtrConst(struct_type.index.unwrap() orelse return 0).fields.count(),5402 .struct_type => |struct_type| ip.structPtrConst(struct_type.index.unwrap() orelse return 0).fields.count(),
5403 .anon_struct_type => |anon_struct_type| anon_struct_type.types.len,5403 .anon_struct_type => |anon_struct_type| anon_struct_type.types.len,
...@@ -5407,7 +5407,7 @@ pub fn aggregateTypeLenIncludingSentinel(ip: InternPool, ty: Index) u64 {...@@ -5407,7 +5407,7 @@ pub fn aggregateTypeLenIncludingSentinel(ip: InternPool, ty: Index) u64 {
5407 };5407 };
5408}5408}
54095409
5410pub fn isNoReturn(ip: InternPool, ty: Index) bool {5410pub fn isNoReturn(ip: *const InternPool, ty: Index) bool {
5411 return switch (ty) {5411 return switch (ty) {
5412 .noreturn_type => true,5412 .noreturn_type => true,
5413 else => switch (ip.indexToKey(ty)) {5413 else => switch (ip.indexToKey(ty)) {
...@@ -5420,7 +5420,7 @@ pub fn isNoReturn(ip: InternPool, ty: Index) bool {...@@ -5420,7 +5420,7 @@ pub fn isNoReturn(ip: InternPool, ty: Index) bool {
54205420
5421/// This is a particularly hot function, so we operate directly on encodings5421/// This is a particularly hot function, so we operate directly on encodings
5422/// rather than the more straightforward implementation of calling `indexToKey`.5422/// rather than the more straightforward implementation of calling `indexToKey`.
5423pub fn zigTypeTagOrPoison(ip: InternPool, index: Index) error{GenericPoison}!std.builtin.TypeId {5423pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPoison}!std.builtin.TypeId {
5424 return switch (index) {5424 return switch (index) {
5425 .u1_type,5425 .u1_type,
5426 .u8_type,5426 .u8_type,
src/Liveness.zig+4-4
...@@ -225,7 +225,7 @@ pub fn categorizeOperand(...@@ -225,7 +225,7 @@ pub fn categorizeOperand(
225 air: Air,225 air: Air,
226 inst: Air.Inst.Index,226 inst: Air.Inst.Index,
227 operand: Air.Inst.Index,227 operand: Air.Inst.Index,
228 ip: InternPool,228 ip: *const InternPool,
229) OperandCategory {229) OperandCategory {
230 const air_tags = air.instructions.items(.tag);230 const air_tags = air.instructions.items(.tag);
231 const air_datas = air.instructions.items(.data);231 const air_datas = air.instructions.items(.data);
...@@ -1139,7 +1139,7 @@ fn analyzeInst(...@@ -1139,7 +1139,7 @@ fn analyzeInst(
1139 .aggregate_init => {1139 .aggregate_init => {
1140 const ty_pl = inst_datas[inst].ty_pl;1140 const ty_pl = inst_datas[inst].ty_pl;
1141 const aggregate_ty = a.air.getRefType(ty_pl.ty);1141 const aggregate_ty = a.air.getRefType(ty_pl.ty);
1142 const len = @intCast(usize, aggregate_ty.arrayLenIp(ip.*));1142 const len = @intCast(usize, aggregate_ty.arrayLenIp(ip));
1143 const elements = @ptrCast([]const Air.Inst.Ref, a.air.extra[ty_pl.payload..][0..len]);1143 const elements = @ptrCast([]const Air.Inst.Ref, a.air.extra[ty_pl.payload..][0..len]);
11441144
1145 if (elements.len <= bpi - 1) {1145 if (elements.len <= bpi - 1) {
...@@ -1291,7 +1291,7 @@ fn analyzeOperands(...@@ -1291,7 +1291,7 @@ fn analyzeOperands(
1291 // If our result is unused and the instruction doesn't need to be lowered, backends will1291 // If our result is unused and the instruction doesn't need to be lowered, backends will
1292 // skip the lowering of this instruction, so we don't want to record uses of operands.1292 // skip the lowering of this instruction, so we don't want to record uses of operands.
1293 // That way, we can mark as many instructions as possible unused.1293 // That way, we can mark as many instructions as possible unused.
1294 if (!immediate_death or a.air.mustLower(inst, ip.*)) {1294 if (!immediate_death or a.air.mustLower(inst, ip)) {
1295 // Note that it's important we iterate over the operands backwards, so that if a dying1295 // Note that it's important we iterate over the operands backwards, so that if a dying
1296 // operand is used multiple times we mark its last use as its death.1296 // operand is used multiple times we mark its last use as its death.
1297 var i = operands.len;1297 var i = operands.len;
...@@ -1837,7 +1837,7 @@ fn AnalyzeBigOperands(comptime pass: LivenessPass) type {...@@ -1837,7 +1837,7 @@ fn AnalyzeBigOperands(comptime pass: LivenessPass) type {
1837 // If our result is unused and the instruction doesn't need to be lowered, backends will1837 // If our result is unused and the instruction doesn't need to be lowered, backends will
1838 // skip the lowering of this instruction, so we don't want to record uses of operands.1838 // skip the lowering of this instruction, so we don't want to record uses of operands.
1839 // That way, we can mark as many instructions as possible unused.1839 // That way, we can mark as many instructions as possible unused.
1840 if (big.will_die_immediately and !big.a.air.mustLower(big.inst, ip.*)) return;1840 if (big.will_die_immediately and !big.a.air.mustLower(big.inst, ip)) return;
18411841
1842 const extra_byte = (big.operands_remaining - (bpi - 1)) / 31;1842 const extra_byte = (big.operands_remaining - (bpi - 1)) / 31;
1843 const extra_bit = @intCast(u5, big.operands_remaining - (bpi - 1) - extra_byte * 31);1843 const extra_bit = @intCast(u5, big.operands_remaining - (bpi - 1) - extra_byte * 31);
src/Liveness/Verify.zig+2-2
...@@ -32,7 +32,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {...@@ -32,7 +32,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
32 const tag = self.air.instructions.items(.tag);32 const tag = self.air.instructions.items(.tag);
33 const data = self.air.instructions.items(.data);33 const data = self.air.instructions.items(.data);
34 for (body) |inst| {34 for (body) |inst| {
35 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip.*)) {35 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip)) {
36 // This instruction will not be lowered and should be ignored.36 // This instruction will not be lowered and should be ignored.
37 continue;37 continue;
38 }38 }
...@@ -325,7 +325,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {...@@ -325,7 +325,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
325 .aggregate_init => {325 .aggregate_init => {
326 const ty_pl = data[inst].ty_pl;326 const ty_pl = data[inst].ty_pl;
327 const aggregate_ty = self.air.getRefType(ty_pl.ty);327 const aggregate_ty = self.air.getRefType(ty_pl.ty);
328 const len = @intCast(usize, aggregate_ty.arrayLenIp(ip.*));328 const len = @intCast(usize, aggregate_ty.arrayLenIp(ip));
329 const elements = @ptrCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);329 const elements = @ptrCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
330330
331 var bt = self.liveness.iterateBigTomb(inst);331 var bt = self.liveness.iterateBigTomb(inst);
src/Module.zig+1-1
...@@ -6726,7 +6726,7 @@ pub fn manyConstPtrType(mod: *Module, child_type: Type) Allocator.Error!Type {...@@ -6726,7 +6726,7 @@ pub fn manyConstPtrType(mod: *Module, child_type: Type) Allocator.Error!Type {
6726}6726}
67276727
6728pub fn adjustPtrTypeChild(mod: *Module, ptr_ty: Type, new_child: Type) Allocator.Error!Type {6728pub fn adjustPtrTypeChild(mod: *Module, ptr_ty: Type, new_child: Type) Allocator.Error!Type {
6729 const info = Type.ptrInfoIp(mod.intern_pool, ptr_ty.toIntern());6729 const info = Type.ptrInfoIp(&mod.intern_pool, ptr_ty.toIntern());
6730 return mod.ptrType(.{6730 return mod.ptrType(.{
6731 .elem_type = new_child.toIntern(),6731 .elem_type = new_child.toIntern(),
67326732
src/Sema.zig+1-1
...@@ -33624,7 +33624,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {...@@ -33624,7 +33624,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3362433624
33625/// Returns the type of the AIR instruction.33625/// Returns the type of the AIR instruction.
33626fn typeOf(sema: *Sema, inst: Air.Inst.Ref) Type {33626fn typeOf(sema: *Sema, inst: Air.Inst.Ref) Type {
33627 return sema.getTmpAir().typeOf(inst, sema.mod.intern_pool);33627 return sema.getTmpAir().typeOf(inst, &sema.mod.intern_pool);
33628}33628}
3362933629
33630pub fn getTmpAir(sema: Sema) Air {33630pub fn getTmpAir(sema: Sema) Air {
src/arch/aarch64/CodeGen.zig+3-3
...@@ -660,7 +660,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -660,7 +660,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
660660
661 for (body) |inst| {661 for (body) |inst| {
662 // TODO: remove now-redundant isUnused calls from AIR handler functions662 // TODO: remove now-redundant isUnused calls from AIR handler functions
663 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip.*))663 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip))
664 continue;664 continue;
665665
666 const old_air_bookkeeping = self.air_bookkeeping;666 const old_air_bookkeeping = self.air_bookkeeping;
...@@ -6412,10 +6412,10 @@ fn registerAlias(self: *Self, reg: Register, ty: Type) Register {...@@ -6412,10 +6412,10 @@ fn registerAlias(self: *Self, reg: Register, ty: Type) Register {
64126412
6413fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {6413fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
6414 const mod = self.bin_file.options.module.?;6414 const mod = self.bin_file.options.module.?;
6415 return self.air.typeOf(inst, mod.intern_pool);6415 return self.air.typeOf(inst, &mod.intern_pool);
6416}6416}
64176417
6418fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {6418fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
6419 const mod = self.bin_file.options.module.?;6419 const mod = self.bin_file.options.module.?;
6420 return self.air.typeOfIndex(inst, mod.intern_pool);6420 return self.air.typeOfIndex(inst, &mod.intern_pool);
6421}6421}
src/arch/arm/CodeGen.zig+3-3
...@@ -644,7 +644,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -644,7 +644,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
644644
645 for (body) |inst| {645 for (body) |inst| {
646 // TODO: remove now-redundant isUnused calls from AIR handler functions646 // TODO: remove now-redundant isUnused calls from AIR handler functions
647 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip.*))647 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip))
648 continue;648 continue;
649649
650 const old_air_bookkeeping = self.air_bookkeeping;650 const old_air_bookkeeping = self.air_bookkeeping;
...@@ -6317,10 +6317,10 @@ fn parseRegName(name: []const u8) ?Register {...@@ -6317,10 +6317,10 @@ fn parseRegName(name: []const u8) ?Register {
63176317
6318fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {6318fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
6319 const mod = self.bin_file.options.module.?;6319 const mod = self.bin_file.options.module.?;
6320 return self.air.typeOf(inst, mod.intern_pool);6320 return self.air.typeOf(inst, &mod.intern_pool);
6321}6321}
63226322
6323fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {6323fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
6324 const mod = self.bin_file.options.module.?;6324 const mod = self.bin_file.options.module.?;
6325 return self.air.typeOfIndex(inst, mod.intern_pool);6325 return self.air.typeOfIndex(inst, &mod.intern_pool);
6326}6326}
src/arch/riscv64/CodeGen.zig+3-3
...@@ -478,7 +478,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -478,7 +478,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
478478
479 for (body) |inst| {479 for (body) |inst| {
480 // TODO: remove now-redundant isUnused calls from AIR handler functions480 // TODO: remove now-redundant isUnused calls from AIR handler functions
481 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip.*))481 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip))
482 continue;482 continue;
483483
484 const old_air_bookkeeping = self.air_bookkeeping;484 const old_air_bookkeeping = self.air_bookkeeping;
...@@ -2737,10 +2737,10 @@ fn parseRegName(name: []const u8) ?Register {...@@ -2737,10 +2737,10 @@ fn parseRegName(name: []const u8) ?Register {
27372737
2738fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {2738fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
2739 const mod = self.bin_file.options.module.?;2739 const mod = self.bin_file.options.module.?;
2740 return self.air.typeOf(inst, mod.intern_pool);2740 return self.air.typeOf(inst, &mod.intern_pool);
2741}2741}
27422742
2743fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {2743fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
2744 const mod = self.bin_file.options.module.?;2744 const mod = self.bin_file.options.module.?;
2745 return self.air.typeOfIndex(inst, mod.intern_pool);2745 return self.air.typeOfIndex(inst, &mod.intern_pool);
2746}2746}
src/arch/sparc64/CodeGen.zig+3-3
...@@ -498,7 +498,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -498,7 +498,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
498498
499 for (body) |inst| {499 for (body) |inst| {
500 // TODO: remove now-redundant isUnused calls from AIR handler functions500 // TODO: remove now-redundant isUnused calls from AIR handler functions
501 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip.*))501 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip))
502 continue;502 continue;
503503
504 const old_air_bookkeeping = self.air_bookkeeping;504 const old_air_bookkeeping = self.air_bookkeeping;
...@@ -4883,10 +4883,10 @@ fn wantSafety(self: *Self) bool {...@@ -4883,10 +4883,10 @@ fn wantSafety(self: *Self) bool {
48834883
4884fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {4884fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
4885 const mod = self.bin_file.options.module.?;4885 const mod = self.bin_file.options.module.?;
4886 return self.air.typeOf(inst, mod.intern_pool);4886 return self.air.typeOf(inst, &mod.intern_pool);
4887}4887}
48884888
4889fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {4889fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
4890 const mod = self.bin_file.options.module.?;4890 const mod = self.bin_file.options.module.?;
4891 return self.air.typeOfIndex(inst, mod.intern_pool);4891 return self.air.typeOfIndex(inst, &mod.intern_pool);
4892}4892}
src/arch/wasm/CodeGen.zig+3-3
...@@ -2076,7 +2076,7 @@ fn genBody(func: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -2076,7 +2076,7 @@ fn genBody(func: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
2076 const ip = &mod.intern_pool;2076 const ip = &mod.intern_pool;
20772077
2078 for (body) |inst| {2078 for (body) |inst| {
2079 if (func.liveness.isUnused(inst) and !func.air.mustLower(inst, ip.*)) {2079 if (func.liveness.isUnused(inst) and !func.air.mustLower(inst, ip)) {
2080 continue;2080 continue;
2081 }2081 }
2082 const old_bookkeeping_value = func.air_bookkeeping;2082 const old_bookkeeping_value = func.air_bookkeeping;
...@@ -7436,10 +7436,10 @@ fn airFrameAddress(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -7436,10 +7436,10 @@ fn airFrameAddress(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
74367436
7437fn typeOf(func: *CodeGen, inst: Air.Inst.Ref) Type {7437fn typeOf(func: *CodeGen, inst: Air.Inst.Ref) Type {
7438 const mod = func.bin_file.base.options.module.?;7438 const mod = func.bin_file.base.options.module.?;
7439 return func.air.typeOf(inst, mod.intern_pool);7439 return func.air.typeOf(inst, &mod.intern_pool);
7440}7440}
74417441
7442fn typeOfIndex(func: *CodeGen, inst: Air.Inst.Index) Type {7442fn typeOfIndex(func: *CodeGen, inst: Air.Inst.Index) Type {
7443 const mod = func.bin_file.base.options.module.?;7443 const mod = func.bin_file.base.options.module.?;
7444 return func.air.typeOfIndex(inst, mod.intern_pool);7444 return func.air.typeOfIndex(inst, &mod.intern_pool);
7445}7445}
src/arch/x86_64/CodeGen.zig+3-3
...@@ -1738,7 +1738,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -1738,7 +1738,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
1738 try self.mir_to_air_map.put(self.gpa, mir_inst, inst);1738 try self.mir_to_air_map.put(self.gpa, mir_inst, inst);
1739 }1739 }
17401740
1741 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip.*)) continue;1741 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip)) continue;
1742 wip_mir_log.debug("{}", .{self.fmtAir(inst)});1742 wip_mir_log.debug("{}", .{self.fmtAir(inst)});
1743 verbose_tracking_log.debug("{}", .{self.fmtTracking()});1743 verbose_tracking_log.debug("{}", .{self.fmtTracking()});
17441744
...@@ -11992,10 +11992,10 @@ fn hasAllFeatures(self: *Self, features: anytype) bool {...@@ -11992,10 +11992,10 @@ fn hasAllFeatures(self: *Self, features: anytype) bool {
1199211992
11993fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {11993fn typeOf(self: *Self, inst: Air.Inst.Ref) Type {
11994 const mod = self.bin_file.options.module.?;11994 const mod = self.bin_file.options.module.?;
11995 return self.air.typeOf(inst, mod.intern_pool);11995 return self.air.typeOf(inst, &mod.intern_pool);
11996}11996}
1199711997
11998fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {11998fn typeOfIndex(self: *Self, inst: Air.Inst.Index) Type {
11999 const mod = self.bin_file.options.module.?;11999 const mod = self.bin_file.options.module.?;
12000 return self.air.typeOfIndex(inst, mod.intern_pool);12000 return self.air.typeOfIndex(inst, &mod.intern_pool);
12001}12001}
src/codegen/c.zig+3-3
...@@ -489,12 +489,12 @@ pub const Function = struct {...@@ -489,12 +489,12 @@ pub const Function = struct {
489489
490 fn typeOf(f: *Function, inst: Air.Inst.Ref) Type {490 fn typeOf(f: *Function, inst: Air.Inst.Ref) Type {
491 const mod = f.object.dg.module;491 const mod = f.object.dg.module;
492 return f.air.typeOf(inst, mod.intern_pool);492 return f.air.typeOf(inst, &mod.intern_pool);
493 }493 }
494494
495 fn typeOfIndex(f: *Function, inst: Air.Inst.Index) Type {495 fn typeOfIndex(f: *Function, inst: Air.Inst.Index) Type {
496 const mod = f.object.dg.module;496 const mod = f.object.dg.module;
497 return f.air.typeOfIndex(inst, mod.intern_pool);497 return f.air.typeOfIndex(inst, &mod.intern_pool);
498 }498 }
499};499};
500500
...@@ -2808,7 +2808,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,...@@ -2808,7 +2808,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,
2808 const air_tags = f.air.instructions.items(.tag);2808 const air_tags = f.air.instructions.items(.tag);
28092809
2810 for (body) |inst| {2810 for (body) |inst| {
2811 if (f.liveness.isUnused(inst) and !f.air.mustLower(inst, ip.*))2811 if (f.liveness.isUnused(inst) and !f.air.mustLower(inst, ip))
2812 continue;2812 continue;
28132813
2814 const result_value = switch (air_tags[inst]) {2814 const result_value = switch (air_tags[inst]) {
src/codegen/llvm.zig+5-5
...@@ -1574,7 +1574,7 @@ pub const Object = struct {...@@ -1574,7 +1574,7 @@ pub const Object = struct {
1574 },1574 },
1575 .Pointer => {1575 .Pointer => {
1576 // Normalize everything that the debug info does not represent.1576 // Normalize everything that the debug info does not represent.
1577 const ptr_info = Type.ptrInfoIp(mod.intern_pool, ty.toIntern());1577 const ptr_info = Type.ptrInfoIp(&mod.intern_pool, ty.toIntern());
15781578
1579 if (ptr_info.sentinel != .none or1579 if (ptr_info.sentinel != .none or
1580 ptr_info.address_space != .generic or1580 ptr_info.address_space != .generic or
...@@ -4330,7 +4330,7 @@ pub const FuncGen = struct {...@@ -4330,7 +4330,7 @@ pub const FuncGen = struct {
4330 const ip = &mod.intern_pool;4330 const ip = &mod.intern_pool;
4331 const air_tags = self.air.instructions.items(.tag);4331 const air_tags = self.air.instructions.items(.tag);
4332 for (body, 0..) |inst, i| {4332 for (body, 0..) |inst, i| {
4333 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip.*))4333 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip))
4334 continue;4334 continue;
43354335
4336 const opt_value: ?*llvm.Value = switch (air_tags[inst]) {4336 const opt_value: ?*llvm.Value = switch (air_tags[inst]) {
...@@ -8055,7 +8055,7 @@ pub const FuncGen = struct {...@@ -8055,7 +8055,7 @@ pub const FuncGen = struct {
8055 const mod = fg.dg.module;8055 const mod = fg.dg.module;
8056 const ip = &mod.intern_pool;8056 const ip = &mod.intern_pool;
8057 for (body_tail[1..]) |body_inst| {8057 for (body_tail[1..]) |body_inst| {
8058 switch (fg.liveness.categorizeOperand(fg.air, body_inst, body_tail[0], ip.*)) {8058 switch (fg.liveness.categorizeOperand(fg.air, body_inst, body_tail[0], ip)) {
8059 .none => continue,8059 .none => continue,
8060 .write, .noret, .complex => return false,8060 .write, .noret, .complex => return false,
8061 .tomb => return true,8061 .tomb => return true,
...@@ -9920,12 +9920,12 @@ pub const FuncGen = struct {...@@ -9920,12 +9920,12 @@ pub const FuncGen = struct {
99209920
9921 fn typeOf(fg: *FuncGen, inst: Air.Inst.Ref) Type {9921 fn typeOf(fg: *FuncGen, inst: Air.Inst.Ref) Type {
9922 const mod = fg.dg.module;9922 const mod = fg.dg.module;
9923 return fg.air.typeOf(inst, mod.intern_pool);9923 return fg.air.typeOf(inst, &mod.intern_pool);
9924 }9924 }
99259925
9926 fn typeOfIndex(fg: *FuncGen, inst: Air.Inst.Index) Type {9926 fn typeOfIndex(fg: *FuncGen, inst: Air.Inst.Index) Type {
9927 const mod = fg.dg.module;9927 const mod = fg.dg.module;
9928 return fg.air.typeOfIndex(inst, mod.intern_pool);9928 return fg.air.typeOfIndex(inst, &mod.intern_pool);
9929 }9929 }
9930};9930};
99319931
src/codegen/spirv.zig+3-3
...@@ -1688,7 +1688,7 @@ pub const DeclGen = struct {...@@ -1688,7 +1688,7 @@ pub const DeclGen = struct {
1688 const mod = self.module;1688 const mod = self.module;
1689 const ip = &mod.intern_pool;1689 const ip = &mod.intern_pool;
1690 // TODO: remove now-redundant isUnused calls from AIR handler functions1690 // TODO: remove now-redundant isUnused calls from AIR handler functions
1691 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip.*))1691 if (self.liveness.isUnused(inst) and !self.air.mustLower(inst, ip))
1692 return;1692 return;
16931693
1694 const air_tags = self.air.instructions.items(.tag);1694 const air_tags = self.air.instructions.items(.tag);
...@@ -3339,11 +3339,11 @@ pub const DeclGen = struct {...@@ -3339,11 +3339,11 @@ pub const DeclGen = struct {
33393339
3340 fn typeOf(self: *DeclGen, inst: Air.Inst.Ref) Type {3340 fn typeOf(self: *DeclGen, inst: Air.Inst.Ref) Type {
3341 const mod = self.module;3341 const mod = self.module;
3342 return self.air.typeOf(inst, mod.intern_pool);3342 return self.air.typeOf(inst, &mod.intern_pool);
3343 }3343 }
33443344
3345 fn typeOfIndex(self: *DeclGen, inst: Air.Inst.Index) Type {3345 fn typeOfIndex(self: *DeclGen, inst: Air.Inst.Index) Type {
3346 const mod = self.module;3346 const mod = self.module;
3347 return self.air.typeOfIndex(inst, mod.intern_pool);3347 return self.air.typeOfIndex(inst, &mod.intern_pool);
3348 }3348 }
3349};3349};
src/print_air.zig+1-1
...@@ -978,6 +978,6 @@ const Writer = struct {...@@ -978,6 +978,6 @@ const Writer = struct {
978978
979 fn typeOfIndex(w: *Writer, inst: Air.Inst.Index) Type {979 fn typeOfIndex(w: *Writer, inst: Air.Inst.Index) Type {
980 const mod = w.module;980 const mod = w.module;
981 return w.air.typeOfIndex(inst, mod.intern_pool);981 return w.air.typeOfIndex(inst, &mod.intern_pool);
982 }982 }
983};983};
src/type.zig+10-10
...@@ -102,7 +102,7 @@ pub const Type = struct {...@@ -102,7 +102,7 @@ pub const Type = struct {
102 };102 };
103 }103 }
104104
105 pub fn ptrInfoIp(ip: InternPool, ty: InternPool.Index) InternPool.Key.PtrType {105 pub fn ptrInfoIp(ip: *const InternPool, ty: InternPool.Index) InternPool.Key.PtrType {
106 return switch (ip.indexToKey(ty)) {106 return switch (ip.indexToKey(ty)) {
107 .ptr_type => |p| p,107 .ptr_type => |p| p,
108 .opt_type => |child| switch (ip.indexToKey(child)) {108 .opt_type => |child| switch (ip.indexToKey(child)) {
...@@ -114,7 +114,7 @@ pub const Type = struct {...@@ -114,7 +114,7 @@ pub const Type = struct {
114 }114 }
115115
116 pub fn ptrInfo(ty: Type, mod: *const Module) Payload.Pointer.Data {116 pub fn ptrInfo(ty: Type, mod: *const Module) Payload.Pointer.Data {
117 return Payload.Pointer.Data.fromKey(ptrInfoIp(mod.intern_pool, ty.toIntern()));117 return Payload.Pointer.Data.fromKey(ptrInfoIp(&mod.intern_pool, ty.toIntern()));
118 }118 }
119119
120 pub fn eql(a: Type, b: Type, mod: *const Module) bool {120 pub fn eql(a: Type, b: Type, mod: *const Module) bool {
...@@ -1832,10 +1832,10 @@ pub const Type = struct {...@@ -1832,10 +1832,10 @@ pub const Type = struct {
1832 }1832 }
18331833
1834 pub fn isVolatilePtr(ty: Type, mod: *const Module) bool {1834 pub fn isVolatilePtr(ty: Type, mod: *const Module) bool {
1835 return isVolatilePtrIp(ty, mod.intern_pool);1835 return isVolatilePtrIp(ty, &mod.intern_pool);
1836 }1836 }
18371837
1838 pub fn isVolatilePtrIp(ty: Type, ip: InternPool) bool {1838 pub fn isVolatilePtrIp(ty: Type, ip: *const InternPool) bool {
1839 return switch (ip.indexToKey(ty.toIntern())) {1839 return switch (ip.indexToKey(ty.toIntern())) {
1840 .ptr_type => |ptr_type| ptr_type.is_volatile,1840 .ptr_type => |ptr_type| ptr_type.is_volatile,
1841 else => false,1841 else => false,
...@@ -1920,10 +1920,10 @@ pub const Type = struct {...@@ -1920,10 +1920,10 @@ pub const Type = struct {
1920 /// For *T, returns T.1920 /// For *T, returns T.
1921 /// For [*]T, returns T.1921 /// For [*]T, returns T.
1922 pub fn childType(ty: Type, mod: *const Module) Type {1922 pub fn childType(ty: Type, mod: *const Module) Type {
1923 return childTypeIp(ty, mod.intern_pool);1923 return childTypeIp(ty, &mod.intern_pool);
1924 }1924 }
19251925
1926 pub fn childTypeIp(ty: Type, ip: InternPool) Type {1926 pub fn childTypeIp(ty: Type, ip: *const InternPool) Type {
1927 return ip.childType(ty.toIntern()).toType();1927 return ip.childType(ty.toIntern()).toType();
1928 }1928 }
19291929
...@@ -2164,10 +2164,10 @@ pub const Type = struct {...@@ -2164,10 +2164,10 @@ pub const Type = struct {
21642164
2165 /// Asserts the type is an array or vector or struct.2165 /// Asserts the type is an array or vector or struct.
2166 pub fn arrayLen(ty: Type, mod: *const Module) u64 {2166 pub fn arrayLen(ty: Type, mod: *const Module) u64 {
2167 return arrayLenIp(ty, mod.intern_pool);2167 return arrayLenIp(ty, &mod.intern_pool);
2168 }2168 }
21692169
2170 pub fn arrayLenIp(ty: Type, ip: InternPool) u64 {2170 pub fn arrayLenIp(ty: Type, ip: *const InternPool) u64 {
2171 return switch (ip.indexToKey(ty.toIntern())) {2171 return switch (ip.indexToKey(ty.toIntern())) {
2172 .vector_type => |vector_type| vector_type.len,2172 .vector_type => |vector_type| vector_type.len,
2173 .array_type => |array_type| array_type.len,2173 .array_type => |array_type| array_type.len,
...@@ -2385,10 +2385,10 @@ pub const Type = struct {...@@ -2385,10 +2385,10 @@ pub const Type = struct {
23852385
2386 /// Asserts the type is a function or a function pointer.2386 /// Asserts the type is a function or a function pointer.
2387 pub fn fnReturnType(ty: Type, mod: *Module) Type {2387 pub fn fnReturnType(ty: Type, mod: *Module) Type {
2388 return fnReturnTypeIp(ty, mod.intern_pool);2388 return fnReturnTypeIp(ty, &mod.intern_pool);
2389 }2389 }
23902390
2391 pub fn fnReturnTypeIp(ty: Type, ip: InternPool) Type {2391 pub fn fnReturnTypeIp(ty: Type, ip: *const InternPool) Type {
2392 return switch (ip.indexToKey(ty.toIntern())) {2392 return switch (ip.indexToKey(ty.toIntern())) {
2393 .ptr_type => |ptr_type| ip.indexToKey(ptr_type.elem_type).func_type.return_type,2393 .ptr_type => |ptr_type| ip.indexToKey(ptr_type.elem_type).func_type.return_type,
2394 .func_type => |func_type| func_type.return_type,2394 .func_type => |func_type| func_type.return_type,