| ... | @@ -3618,7 +3618,7 @@ fn updateLazyType( | ... | @@ -3618,7 +3618,7 @@ fn updateLazyType( |
| 3618 | try wip_nav.strp(name); | 3618 | try wip_nav.strp(name); |
| 3619 | if (array_type.sentinel != .none) try wip_nav.blockValue(src_loc, .fromInterned(array_type.sentinel)); | 3619 | if (array_type.sentinel != .none) try wip_nav.blockValue(src_loc, .fromInterned(array_type.sentinel)); |
| 3620 | try wip_nav.refType(array_child_type); | 3620 | try wip_nav.refType(array_child_type); |
| 3621 | try wip_nav.abbrevCode(.array_index); | 3621 | try wip_nav.abbrevCode(.array_len); |
| 3622 | try wip_nav.refType(.usize); | 3622 | try wip_nav.refType(.usize); |
| 3623 | try diw.writeUleb128(array_type.len); | 3623 | try diw.writeUleb128(array_type.len); |
| 3624 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); | 3624 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); |
| ... | @@ -3627,7 +3627,7 @@ fn updateLazyType( | ... | @@ -3627,7 +3627,7 @@ fn updateLazyType( |
| 3627 | try wip_nav.abbrevCode(.vector_type); | 3627 | try wip_nav.abbrevCode(.vector_type); |
| 3628 | try wip_nav.strp(name); | 3628 | try wip_nav.strp(name); |
| 3629 | try wip_nav.refType(.fromInterned(vector_type.child)); | 3629 | try wip_nav.refType(.fromInterned(vector_type.child)); |
| 3630 | try wip_nav.abbrevCode(.array_index); | 3630 | try wip_nav.abbrevCode(.array_len); |
| 3631 | try wip_nav.refType(.usize); | 3631 | try wip_nav.refType(.usize); |
| 3632 | try diw.writeUleb128(vector_type.len); | 3632 | try diw.writeUleb128(vector_type.len); |
| 3633 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); | 3633 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); |
| ... | @@ -4177,24 +4177,38 @@ fn updateLazyValue( | ... | @@ -4177,24 +4177,38 @@ fn updateLazyValue( |
| 4177 | try wip_nav.refType(.fromInterned(float.ty)); | 4177 | try wip_nav.refType(.fromInterned(float.ty)); |
| 4178 | }, | 4178 | }, |
| 4179 | .ptr => |ptr| { | 4179 | .ptr => |ptr| { |
| | 4180 | const Access = union(enum) { |
| | 4181 | index: u64, |
| | 4182 | field: InternPool.NullTerminatedString, |
| | 4183 | synthetic_field: []const u8, |
| | 4184 | tuple_index: u32, |
| | 4185 | }; |
| | 4186 | var zero_bit_accesses: std.ArrayList(Access) = .empty; |
| | 4187 | defer zero_bit_accesses.deinit(dwarf.gpa); |
| 4180 | location: { | 4188 | location: { |
| 4181 | var base_addr = ptr.base_addr; | 4189 | var base_addr = ptr.base_addr; |
| 4182 | var byte_offset = ptr.byte_offset; | 4190 | var byte_offset = ptr.byte_offset; |
| 4183 | const base_unit, const base_entry = while (true) { | 4191 | const base_unit, const base_entry = while (true) { |
| 4184 | const base_ptr = base_ptr: switch (base_addr) { | 4192 | const base_ptr, const access: Access = base_ptr_access: switch (base_addr) { |
| 4185 | .nav => |nav_index| break try wip_nav.getNavEntry(nav_index), | 4193 | .nav => |nav_index| break try wip_nav.getNavEntry(nav_index), |
| 4186 | .comptime_alloc, .comptime_field => unreachable, | 4194 | .comptime_alloc, .comptime_field => unreachable, |
| 4187 | .uav => |uav| { | 4195 | .uav => |uav| { |
| 4188 | const uav_ty: Type = .fromInterned(ip.typeOf(uav.val)); | 4196 | const uav_ty: Type = .fromInterned(ip.typeOf(uav.val)); |
| 4189 | if (try uav_ty.onePossibleValue(pt)) |_| { | 4197 | if (try uav_ty.onePossibleValue(pt)) |_| { |
| 4190 | try wip_nav.abbrevCode(.udata_comptime_value); | 4198 | try wip_nav.abbrevCode(if (zero_bit_accesses.items.len > 0) |
| | 4199 | .aggregate_udata_comptime_value |
| | 4200 | else |
| | 4201 | .udata_comptime_value); |
| 4191 | try diw.writeUleb128(ip.indexToKey(uav.orig_ty).ptr_type.flags.alignment.toByteUnits() orelse | 4202 | try diw.writeUleb128(ip.indexToKey(uav.orig_ty).ptr_type.flags.alignment.toByteUnits() orelse |
| 4192 | uav_ty.abiAlignment(zcu).toByteUnits().?); | 4203 | uav_ty.abiAlignment(zcu).toByteUnits().?); |
| 4193 | break :location; | 4204 | break :location; |
| 4194 | } else break try wip_nav.getValueEntry(.fromInterned(uav.val)); | 4205 | } else break try wip_nav.getValueEntry(.fromInterned(uav.val)); |
| 4195 | }, | 4206 | }, |
| 4196 | .int => { | 4207 | .int => { |
| 4197 | try wip_nav.abbrevCode(.udata_comptime_value); | 4208 | try wip_nav.abbrevCode(if (zero_bit_accesses.items.len > 0) |
| | 4209 | .aggregate_udata_comptime_value |
| | 4210 | else |
| | 4211 | .udata_comptime_value); |
| 4198 | try diw.writeUleb128(byte_offset); | 4212 | try diw.writeUleb128(byte_offset); |
| 4199 | break :location; | 4213 | break :location; |
| 4200 | }, | 4214 | }, |
| ... | @@ -4203,16 +4217,40 @@ fn updateLazyValue( | ... | @@ -4203,16 +4217,40 @@ fn updateLazyValue( |
| 4203 | byte_offset += codegen.errUnionPayloadOffset(.fromInterned(ip.indexToKey( | 4217 | byte_offset += codegen.errUnionPayloadOffset(.fromInterned(ip.indexToKey( |
| 4204 | ip.indexToKey(base_ptr.ty).ptr_type.child, | 4218 | ip.indexToKey(base_ptr.ty).ptr_type.child, |
| 4205 | ).error_union_type.payload_type), zcu); | 4219 | ).error_union_type.payload_type), zcu); |
| 4206 | break :base_ptr base_ptr; | 4220 | break :base_ptr_access .{ base_ptr, .{ .synthetic_field = "value" } }; |
| | 4221 | }, |
| | 4222 | .opt_payload => |opt_ptr| .{ ip.indexToKey(opt_ptr).ptr, .{ .synthetic_field = "?" } }, |
| | 4223 | .field => |field| { |
| | 4224 | const base_ptr = ip.indexToKey(field.base).ptr; |
| | 4225 | const agg_ty: Type = .fromInterned(ip.indexToKey(base_ptr.ty).ptr_type.child); |
| | 4226 | break :base_ptr_access .{ |
| | 4227 | base_ptr, |
| | 4228 | if (agg_ty.isSlice(zcu)) .{ .synthetic_field = switch (field.index) { |
| | 4229 | Value.slice_ptr_index => "ptr", |
| | 4230 | Value.slice_len_index => "len", |
| | 4231 | else => unreachable, |
| | 4232 | } } else if (agg_ty.structFieldName(@intCast(field.index), zcu).unwrap()) |field_name| |
| | 4233 | .{ .field = field_name } |
| | 4234 | else |
| | 4235 | .{ .tuple_index = @intCast(field.index) }, |
| | 4236 | }; |
| | 4237 | }, |
| | 4238 | .arr_elem => |arr_elem| .{ |
| | 4239 | ip.indexToKey(arr_elem.base).ptr, |
| | 4240 | .{ .index = arr_elem.index }, |
| 4207 | }, | 4241 | }, |
| 4208 | .opt_payload => |opt_ptr| ip.indexToKey(opt_ptr).ptr, | | |
| 4209 | .field => unreachable, | | |
| 4210 | .arr_elem => unreachable, | | |
| 4211 | }; | 4242 | }; |
| 4212 | base_addr = base_ptr.base_addr; | 4243 | base_addr = base_ptr.base_addr; |
| 4213 | byte_offset += base_ptr.byte_offset; | 4244 | byte_offset += base_ptr.byte_offset; |
| | 4245 | if (Type.fromInterned(ip.indexToKey(base_ptr.ty).ptr_type.child).hasRuntimeBits(zcu)) |
| | 4246 | assert(access != .index) |
| | 4247 | else |
| | 4248 | try zero_bit_accesses.append(dwarf.gpa, access); |
| 4214 | }; | 4249 | }; |
| 4215 | try wip_nav.abbrevCode(.location_comptime_value); | 4250 | try wip_nav.abbrevCode(if (zero_bit_accesses.items.len > 0) |
| | 4251 | .aggregate_location_comptime_value |
| | 4252 | else |
| | 4253 | .location_comptime_value); |
| 4216 | try wip_nav.infoExprLoc(.{ .implicit_pointer = .{ | 4254 | try wip_nav.infoExprLoc(.{ .implicit_pointer = .{ |
| 4217 | .unit = base_unit, | 4255 | .unit = base_unit, |
| 4218 | .entry = base_entry, | 4256 | .entry = base_entry, |
| ... | @@ -4220,6 +4258,29 @@ fn updateLazyValue( | ... | @@ -4220,6 +4258,29 @@ fn updateLazyValue( |
| 4220 | } }); | 4258 | } }); |
| 4221 | } | 4259 | } |
| 4222 | try wip_nav.refType(.fromInterned(ptr.ty)); | 4260 | try wip_nav.refType(.fromInterned(ptr.ty)); |
| | 4261 | if (zero_bit_accesses.items.len > 0) { |
| | 4262 | for (zero_bit_accesses.items) |access| switch (access) { |
| | 4263 | .index => |index| { |
| | 4264 | try wip_nav.abbrevCode(.array_index); |
| | 4265 | try diw.writeUleb128(index); |
| | 4266 | }, |
| | 4267 | .field => |field| { |
| | 4268 | try wip_nav.abbrevCode(.field); |
| | 4269 | try wip_nav.strp(field.toSlice(ip)); |
| | 4270 | }, |
| | 4271 | .synthetic_field => |field| { |
| | 4272 | try wip_nav.abbrevCode(.field); |
| | 4273 | try wip_nav.strp(field); |
| | 4274 | }, |
| | 4275 | .tuple_index => |index| { |
| | 4276 | try wip_nav.abbrevCode(.field); |
| | 4277 | var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined; |
| | 4278 | const field_name = std.fmt.bufPrint(&field_name_buf, "{d}", .{index}) catch unreachable; |
| | 4279 | try wip_nav.strp(field_name); |
| | 4280 | }, |
| | 4281 | }; |
| | 4282 | try diw.writeUleb128(@intFromEnum(AbbrevCode.null)); |
| | 4283 | } |
| 4223 | }, | 4284 | }, |
| 4224 | .slice => |slice| { | 4285 | .slice => |slice| { |
| 4225 | try wip_nav.abbrevCode(.aggregate_comptime_value); | 4286 | try wip_nav.abbrevCode(.aggregate_comptime_value); |
| ... | @@ -4387,12 +4448,7 @@ fn updateLazyValue( | ... | @@ -4387,12 +4448,7 @@ fn updateLazyValue( |
| 4387 | try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.written()); | 4448 | try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.written()); |
| 4388 | } | 4449 | } |
| 4389 | | 4450 | |
| 4390 | fn optRepr(opt_child_type: Type, zcu: *const Zcu) enum { | 4451 | fn optRepr(opt_child_type: Type, zcu: *const Zcu) enum { unpacked, opv_null, error_set, pointer } { |
| 4391 | unpacked, | | |
| 4392 | opv_null, | | |
| 4393 | error_set, | | |
| 4394 | pointer, | | |
| 4395 | } { | | |
| 4396 | if (opt_child_type.isNoReturn(zcu)) return .opv_null; | 4452 | if (opt_child_type.isNoReturn(zcu)) return .opv_null; |
| 4397 | return switch (opt_child_type.toIntern()) { | 4453 | return switch (opt_child_type.toIntern()) { |
| 4398 | .anyerror_type => .error_set, | 4454 | .anyerror_type => .error_set, |
| ... | @@ -5233,6 +5289,7 @@ const AbbrevCode = enum { | ... | @@ -5233,6 +5289,7 @@ const AbbrevCode = enum { |
| 5233 | module, | 5289 | module, |
| 5234 | empty_file, | 5290 | empty_file, |
| 5235 | file, | 5291 | file, |
| | 5292 | field, |
| 5236 | signed_enum_field, | 5293 | signed_enum_field, |
| 5237 | unsigned_enum_field, | 5294 | unsigned_enum_field, |
| 5238 | big_enum_field, | 5295 | big_enum_field, |
| ... | @@ -5261,6 +5318,7 @@ const AbbrevCode = enum { | ... | @@ -5261,6 +5318,7 @@ const AbbrevCode = enum { |
| 5261 | array_sentinel_type, | 5318 | array_sentinel_type, |
| 5262 | vector_type, | 5319 | vector_type, |
| 5263 | array_index, | 5320 | array_index, |
| | 5321 | array_len, |
| 5264 | nullary_func_type, | 5322 | nullary_func_type, |
| 5265 | func_type, | 5323 | func_type, |
| 5266 | func_type_param, | 5324 | func_type_param, |
| ... | @@ -5308,10 +5366,12 @@ const AbbrevCode = enum { | ... | @@ -5308,10 +5366,12 @@ const AbbrevCode = enum { |
| 5308 | data16_comptime_value, | 5366 | data16_comptime_value, |
| 5309 | sdata_comptime_value, | 5367 | sdata_comptime_value, |
| 5310 | udata_comptime_value, | 5368 | udata_comptime_value, |
| | 5369 | aggregate_udata_comptime_value, |
| 5311 | block_comptime_value, | 5370 | block_comptime_value, |
| 5312 | string_comptime_value, | 5371 | string_comptime_value, |
| 5313 | location_comptime_value, | 5372 | location_comptime_value, |
| 5314 | aggregate_comptime_value, | 5373 | aggregate_comptime_value, |
| | 5374 | aggregate_location_comptime_value, |
| 5315 | comptime_value_field_runtime_bits, | 5375 | comptime_value_field_runtime_bits, |
| 5316 | comptime_value_field_comptime_state, | 5376 | comptime_value_field_comptime_state, |
| 5317 | comptime_value_elem_runtime_bits, | 5377 | comptime_value_elem_runtime_bits, |
| ... | @@ -5721,6 +5781,12 @@ const AbbrevCode = enum { | ... | @@ -5721,6 +5781,12 @@ const AbbrevCode = enum { |
| 5721 | .{ .alignment, .udata }, | 5781 | .{ .alignment, .udata }, |
| 5722 | }, | 5782 | }, |
| 5723 | }, | 5783 | }, |
| | 5784 | .field = .{ |
| | 5785 | .tag = .member, |
| | 5786 | .attrs = &.{ |
| | 5787 | .{ .name, .strp }, |
| | 5788 | }, |
| | 5789 | }, |
| 5724 | .signed_enum_field = .{ | 5790 | .signed_enum_field = .{ |
| 5725 | .tag = .enumerator, | 5791 | .tag = .enumerator, |
| 5726 | .attrs = &.{ | 5792 | .attrs = &.{ |
| ... | @@ -5936,6 +6002,12 @@ const AbbrevCode = enum { | ... | @@ -5936,6 +6002,12 @@ const AbbrevCode = enum { |
| 5936 | }, | 6002 | }, |
| 5937 | }, | 6003 | }, |
| 5938 | .array_index = .{ | 6004 | .array_index = .{ |
| | 6005 | .tag = .subrange_type, |
| | 6006 | .attrs = &.{ |
| | 6007 | .{ .lower_bound, .udata }, |
| | 6008 | }, |
| | 6009 | }, |
| | 6010 | .array_len = .{ |
| 5939 | .tag = .subrange_type, | 6011 | .tag = .subrange_type, |
| 5940 | .attrs = &.{ | 6012 | .attrs = &.{ |
| 5941 | .{ .type, .ref_addr }, | 6013 | .{ .type, .ref_addr }, |
| ... | @@ -6325,6 +6397,14 @@ const AbbrevCode = enum { | ... | @@ -6325,6 +6397,14 @@ const AbbrevCode = enum { |
| 6325 | .{ .type, .ref_addr }, | 6397 | .{ .type, .ref_addr }, |
| 6326 | }, | 6398 | }, |
| 6327 | }, | 6399 | }, |
| | 6400 | .aggregate_udata_comptime_value = .{ |
| | 6401 | .tag = .ZIG_comptime_value, |
| | 6402 | .children = true, |
| | 6403 | .attrs = &.{ |
| | 6404 | .{ .const_value, .udata }, |
| | 6405 | .{ .type, .ref_addr }, |
| | 6406 | }, |
| | 6407 | }, |
| 6328 | .block_comptime_value = .{ | 6408 | .block_comptime_value = .{ |
| 6329 | .tag = .ZIG_comptime_value, | 6409 | .tag = .ZIG_comptime_value, |
| 6330 | .attrs = &.{ | 6410 | .attrs = &.{ |
| ... | @@ -6353,6 +6433,14 @@ const AbbrevCode = enum { | ... | @@ -6353,6 +6433,14 @@ const AbbrevCode = enum { |
| 6353 | .{ .type, .ref_addr }, | 6433 | .{ .type, .ref_addr }, |
| 6354 | }, | 6434 | }, |
| 6355 | }, | 6435 | }, |
| | 6436 | .aggregate_location_comptime_value = .{ |
| | 6437 | .tag = .ZIG_comptime_value, |
| | 6438 | .children = true, |
| | 6439 | .attrs = &.{ |
| | 6440 | .{ .location, .exprloc }, |
| | 6441 | .{ .type, .ref_addr }, |
| | 6442 | }, |
| | 6443 | }, |
| 6356 | .comptime_value_field_runtime_bits = .{ | 6444 | .comptime_value_field_runtime_bits = .{ |
| 6357 | .tag = .member, | 6445 | .tag = .member, |
| 6358 | .attrs = &.{ | 6446 | .attrs = &.{ |