| ... | @@ -637,7 +637,7 @@ pub const WipNav = struct { | ... | @@ -637,7 +637,7 @@ pub const WipNav = struct { |
| 637 | pub const Debug = struct { | 637 | pub const Debug = struct { |
| 638 | wip_nav: WipNav, | 638 | wip_nav: WipNav, |
| 639 | pt: Zcu.PerThread, | 639 | pt: Zcu.PerThread, |
| 640 | any_children: bool, | 640 | empty: bool, |
| 641 | blocks: std.ArrayList(struct { | 641 | blocks: std.ArrayList(struct { |
| 642 | abbrev_code: u32, | 642 | abbrev_code: u32, |
| 643 | low_pc_off: usize, | 643 | low_pc_off: usize, |
| ... | @@ -763,14 +763,19 @@ pub const WipNav = struct { | ... | @@ -763,14 +763,19 @@ pub const WipNav = struct { |
| 763 | } | 763 | } |
| 764 | fn finishDebugInfo(debug: *Debug, func_length: u64) link.EmitError!void { | 764 | fn finishDebugInfo(debug: *Debug, func_length: u64) link.EmitError!void { |
| 765 | const dwarf = debug.wip_nav.dwarf; | 765 | const dwarf = debug.wip_nav.dwarf; |
| 766 | const di_w = &debug.info_writer.interface; | 766 | const di_nw = &debug.info_writer; |
| | 767 | const di_w = &di_nw.interface; |
| 767 | std.mem.writeInt( | 768 | std.mem.writeInt( |
| 768 | u32, | 769 | u32, |
| 769 | di_w.buffered()[debug.info_func_length_offset..][0..4], | 770 | di_w.buffered()[debug.info_func_length_offset..][0..4], |
| 770 | @intCast(func_length), | 771 | @intCast(func_length), |
| 771 | dwarf.endian, | 772 | dwarf.endian, |
| 772 | ); | 773 | ); |
| 773 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | 774 | if (debug.empty) std.leb.writeUnsignedFixed( |
| | 775 | AbbrevCode.decl_size, |
| | 776 | di_w.buffered()[0..AbbrevCode.decl_size], |
| | 777 | @intCast(try dwarf.refAbbrevCode(di_nw.mf, .decl_empty_func)), |
| | 778 | ) else try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 774 | try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen()); | 779 | try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen()); |
| 775 | } | 780 | } |
| 776 | fn finishDebugLine(debug: *Debug) link.EmitError!void { | 781 | fn finishDebugLine(debug: *Debug) link.EmitError!void { |
| ... | @@ -808,7 +813,7 @@ pub const WipNav = struct { | ... | @@ -808,7 +813,7 @@ pub const WipNav = struct { |
| 808 | if (opt_name) |name| try dwarf.strp(&dwarf.debug_str, di_nw, name); | 813 | if (opt_name) |name| try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| 809 | try dwarf.refType(debug.pt, di_nw, ty); | 814 | try dwarf.refType(debug.pt, di_nw, ty); |
| 810 | try dwarf.exprLoc(di_nw, loc); | 815 | try dwarf.exprLoc(di_nw, loc); |
| 811 | debug.any_children = true; | 816 | debug.empty = false; |
| 812 | } | 817 | } |
| 813 | | 818 | |
| 814 | pub const LocalConstTag = enum { comptime_arg, local_const }; | 819 | pub const LocalConstTag = enum { comptime_arg, local_const }; |
| ... | @@ -862,7 +867,7 @@ pub const WipNav = struct { | ... | @@ -862,7 +867,7 @@ pub const WipNav = struct { |
| 862 | try dwarf.refType(pt, di_nw, ty); | 867 | try dwarf.refType(pt, di_nw, ty); |
| 863 | if (ty_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, val); | 868 | if (ty_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, val); |
| 864 | if (ty_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, val); | 869 | if (ty_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, val); |
| 865 | debug.any_children = true; | 870 | debug.empty = false; |
| 866 | } | 871 | } |
| 867 | | 872 | |
| 868 | pub fn genVarArgsDebugInfo(debug: *Debug) link.Error!void { | 873 | pub fn genVarArgsDebugInfo(debug: *Debug) link.Error!void { |
| ... | @@ -874,7 +879,7 @@ pub const WipNav = struct { | ... | @@ -874,7 +879,7 @@ pub const WipNav = struct { |
| 874 | fn genVarArgsDebugInfoInner(debug: *Debug) link.EmitError!void { | 879 | fn genVarArgsDebugInfoInner(debug: *Debug) link.EmitError!void { |
| 875 | assert(debug.wip_nav.func != .none); | 880 | assert(debug.wip_nav.func != .none); |
| 876 | try debug.wip_nav.dwarf.abbrevCode(&debug.info_writer, .is_var_args); | 881 | try debug.wip_nav.dwarf.abbrevCode(&debug.info_writer, .is_var_args); |
| 877 | debug.any_children = true; | 882 | debug.empty = false; |
| 878 | } | 883 | } |
| 879 | | 884 | |
| 880 | pub fn advanceLineAndPc( | 885 | pub fn advanceLineAndPc( |
| ... | @@ -993,7 +998,7 @@ pub const WipNav = struct { | ... | @@ -993,7 +998,7 @@ pub const WipNav = struct { |
| 993 | try dwarf.addrSym(di_nw, debug.wip_nav.func_si, code_off); | 998 | try dwarf.addrSym(di_nw, debug.wip_nav.func_si, code_off); |
| 994 | block.high_pc = @intCast(di_w.end); | 999 | block.high_pc = @intCast(di_w.end); |
| 995 | try di_w.writeInt(u32, 0, dwarf.endian); | 1000 | try di_w.writeInt(u32, 0, dwarf.endian); |
| 996 | debug.any_children = false; | 1001 | debug.empty = true; |
| 997 | } | 1002 | } |
| 998 | | 1003 | |
| 999 | pub fn leaveBlock(debug: *Debug, code_off: usize) link.Error!void { | 1004 | pub fn leaveBlock(debug: *Debug, code_off: usize) link.Error!void { |
| ... | @@ -1004,26 +1009,23 @@ pub const WipNav = struct { | ... | @@ -1004,26 +1009,23 @@ pub const WipNav = struct { |
| 1004 | } | 1009 | } |
| 1005 | fn leaveBlockInner(debug: *Debug, code_off: usize) link.EmitError!void { | 1010 | fn leaveBlockInner(debug: *Debug, code_off: usize) link.EmitError!void { |
| 1006 | const dwarf = debug.wip_nav.dwarf; | 1011 | const dwarf = debug.wip_nav.dwarf; |
| 1007 | const block_size = comptime uleb128Size(@backingInt(AbbrevCode.block)); | | |
| 1008 | const block = debug.blocks.pop().?; | 1012 | const block = debug.blocks.pop().?; |
| 1009 | | 1013 | |
| 1010 | const di_nw = &debug.info_writer; | 1014 | const di_nw = &debug.info_writer; |
| 1011 | const di_w = &di_nw.interface; | 1015 | const di_w = &di_nw.interface; |
| 1012 | if (debug.any_children) | 1016 | const block_size = comptime uleb128Size(@backingInt(AbbrevCode.block)); |
| 1013 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)) | 1017 | if (debug.empty) std.leb.writeUnsignedFixed( |
| 1014 | else | 1018 | block_size, |
| 1015 | std.leb.writeUnsignedFixed( | 1019 | di_w.buffered()[block.abbrev_code..][0..block_size], |
| 1016 | block_size, | 1020 | @intCast(try dwarf.refAbbrevCode(di_nw.mf, .empty_block)), |
| 1017 | di_w.buffered()[block.abbrev_code..][0..block_size], | 1021 | ) else try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 1018 | @intCast(try dwarf.refAbbrevCode(di_nw.mf, .empty_block)), | | |
| 1019 | ); | | |
| 1020 | std.mem.writeInt( | 1022 | std.mem.writeInt( |
| 1021 | u32, | 1023 | u32, |
| 1022 | di_nw.interface.buffered()[block.high_pc..][0..4], | 1024 | di_nw.interface.buffered()[block.high_pc..][0..4], |
| 1023 | @intCast(code_off - block.low_pc_off), | 1025 | @intCast(code_off - block.low_pc_off), |
| 1024 | dwarf.endian, | 1026 | dwarf.endian, |
| 1025 | ); | 1027 | ); |
| 1026 | debug.any_children = true; | 1028 | debug.empty = false; |
| 1027 | } | 1029 | } |
| 1028 | | 1030 | |
| 1029 | pub fn enterInlineFunc( | 1031 | pub fn enterInlineFunc( |
| ... | @@ -1064,7 +1066,7 @@ pub const WipNav = struct { | ... | @@ -1064,7 +1066,7 @@ pub const WipNav = struct { |
| 1064 | block.high_pc = @intCast(di_w.end); | 1066 | block.high_pc = @intCast(di_w.end); |
| 1065 | try di_w.writeInt(u32, 0, dwarf.endian); | 1067 | try di_w.writeInt(u32, 0, dwarf.endian); |
| 1066 | try debug.setInlineFunc(func); | 1068 | try debug.setInlineFunc(func); |
| 1067 | debug.any_children = false; | 1069 | debug.empty = true; |
| 1068 | } | 1070 | } |
| 1069 | | 1071 | |
| 1070 | pub fn leaveInlineFunc(debug: *Debug, func: InternPool.Index, code_off: usize) link.Error!void { | 1072 | pub fn leaveInlineFunc(debug: *Debug, func: InternPool.Index, code_off: usize) link.Error!void { |
| ... | @@ -1079,19 +1081,16 @@ pub const WipNav = struct { | ... | @@ -1079,19 +1081,16 @@ pub const WipNav = struct { |
| 1079 | code_off: usize, | 1081 | code_off: usize, |
| 1080 | ) link.EmitError!void { | 1082 | ) link.EmitError!void { |
| 1081 | const dwarf = debug.wip_nav.dwarf; | 1083 | const dwarf = debug.wip_nav.dwarf; |
| 1082 | const inlined_func_size = comptime uleb128Size(@backingInt(AbbrevCode.inlined_func)); | | |
| 1083 | const block = debug.blocks.pop().?; | 1084 | const block = debug.blocks.pop().?; |
| 1084 | | 1085 | |
| 1085 | const di_nw = &debug.info_writer; | 1086 | const di_nw = &debug.info_writer; |
| 1086 | const di_w = &di_nw.interface; | 1087 | const di_w = &di_nw.interface; |
| 1087 | if (debug.any_children) | 1088 | const inlined_func_size = comptime uleb128Size(@backingInt(AbbrevCode.inlined_func)); |
| 1088 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)) | 1089 | if (debug.empty) std.leb.writeUnsignedFixed( |
| 1089 | else | 1090 | inlined_func_size, |
| 1090 | std.leb.writeUnsignedFixed( | 1091 | di_w.buffered()[block.abbrev_code..][0..inlined_func_size], |
| 1091 | inlined_func_size, | 1092 | @intCast(try dwarf.refAbbrevCode(di_nw.mf, .empty_inlined_func)), |
| 1092 | di_w.buffered()[block.abbrev_code..][0..inlined_func_size], | 1093 | ) else try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 1093 | @intCast(try dwarf.refAbbrevCode(di_nw.mf, .empty_inlined_func)), | | |
| 1094 | ); | | |
| 1095 | std.mem.writeInt( | 1094 | std.mem.writeInt( |
| 1096 | u32, | 1095 | u32, |
| 1097 | di_w.buffered()[block.high_pc..][0..4], | 1096 | di_w.buffered()[block.high_pc..][0..4], |
| ... | @@ -1099,7 +1098,7 @@ pub const WipNav = struct { | ... | @@ -1099,7 +1098,7 @@ pub const WipNav = struct { |
| 1099 | dwarf.endian, | 1098 | dwarf.endian, |
| 1100 | ); | 1099 | ); |
| 1101 | try debug.setInlineFunc(func); | 1100 | try debug.setInlineFunc(func); |
| 1102 | debug.any_children = true; | 1101 | debug.empty = false; |
| 1103 | } | 1102 | } |
| 1104 | | 1103 | |
| 1105 | pub fn setInlineFunc(debug: *Debug, func: InternPool.Index) link.Error!void { | 1104 | pub fn setInlineFunc(debug: *Debug, func: InternPool.Index) link.Error!void { |
| ... | @@ -1398,25 +1397,26 @@ pub fn getGlobal(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Global.Ind | ... | @@ -1398,25 +1397,26 @@ pub fn getGlobal(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Global.Ind |
| 1398 | if (global_gop.value_ptr.debug_info_ni != .none) return gi; | 1397 | if (global_gop.value_ptr.debug_info_ni != .none) return gi; |
| 1399 | const mod = comp.zcu.?.navFileScope(nav).mod.?; | 1398 | const mod = comp.zcu.?.navFileScope(nav).mod.?; |
| 1400 | assert(!mod.strip); | 1399 | assert(!mod.strip); |
| 1401 | const elf = dwarf.lf.cast(.elf2).?; | 1400 | if (dwarf.lf.cast(.elf2)) |elf| { |
| 1402 | try elf.nodes.ensureUnusedCapacity(gpa, 1); | 1401 | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| 1403 | try elf.dwarf_globals.append(gpa, .{ | 1402 | try elf.dwarf_globals.append(gpa, .{ |
| 1404 | .debug_info_first_target_reloc = .none, | 1403 | .debug_info_first_target_reloc = .none, |
| 1405 | .debug_info_first_node_reloc = .none, | 1404 | .debug_info_first_node_reloc = .none, |
| 1406 | .debug_info_first_symbol_reloc = .none, | 1405 | .debug_info_first_symbol_reloc = .none, |
| 1407 | }); | 1406 | }); |
| 1408 | const unit = dwarf.getUnit(mod).get(dwarf); | 1407 | const unit = dwarf.getUnit(mod).get(dwarf); |
| 1409 | global_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( | 1408 | global_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( |
| 1410 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ | 1409 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ |
| 1411 | .enable_next_moved = true, | 1410 | .enable_next_moved = true, |
| 1412 | }) catch |err| switch (err) { | 1411 | }) catch |err| switch (err) { |
| 1413 | else => |e| return e, | 1412 | else => |e| return e, |
| 1414 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ | 1413 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 1415 | elf.mf.io_err.?, | 1414 | elf.mf.io_err.?, |
| 1416 | }), | 1415 | }), |
| 1417 | }, | 1416 | }, |
| 1418 | .{ .global_debug_info = gi }, | 1417 | .{ .global_debug_info = gi }, |
| 1419 | )); | 1418 | )); |
| | 1419 | } else unreachable; |
| 1420 | return gi; | 1420 | return gi; |
| 1421 | } | 1421 | } |
| 1422 | pub fn getGlobalIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Global.Index { | 1422 | pub fn getGlobalIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Global.Index { |
| ... | @@ -1436,30 +1436,31 @@ pub fn getFunc(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Func.Index { | ... | @@ -1436,30 +1436,31 @@ pub fn getFunc(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Func.Index { |
| 1436 | const fi: Func.Index = @fromBackingInt(@intCast(func_gop.index)); | 1436 | const fi: Func.Index = @fromBackingInt(@intCast(func_gop.index)); |
| 1437 | if (func_gop.value_ptr.debug_info_ni != .none) return fi; | 1437 | if (func_gop.value_ptr.debug_info_ni != .none) return fi; |
| 1438 | const mod = comp.zcu.?.navFileScope(nav).mod.?; | 1438 | const mod = comp.zcu.?.navFileScope(nav).mod.?; |
| 1439 | const elf = dwarf.lf.cast(.elf2).?; | 1439 | if (dwarf.lf.cast(.elf2)) |elf| { |
| 1440 | try elf.nodes.ensureUnusedCapacity(gpa, 1); | 1440 | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| 1441 | try elf.dwarf_funcs.append(gpa, .{ | 1441 | try elf.dwarf_funcs.append(gpa, .{ |
| 1442 | .frame_fde_first_symbol_reloc = .none, | 1442 | .frame_fde_first_symbol_reloc = .none, |
| 1443 | .frame_fde_first_node_reloc = .none, | 1443 | .frame_fde_first_node_reloc = .none, |
| 1444 | .debug_info_first_target_reloc = .none, | 1444 | .debug_info_first_target_reloc = .none, |
| 1445 | .debug_info_first_symbol_reloc = .none, | 1445 | .debug_info_first_symbol_reloc = .none, |
| 1446 | .debug_info_first_node_reloc = .none, | 1446 | .debug_info_first_node_reloc = .none, |
| 1447 | .debug_line_first_symbol_reloc = .none, | 1447 | .debug_line_first_symbol_reloc = .none, |
| 1448 | .debug_line_first_node_reloc = .none, | 1448 | .debug_line_first_node_reloc = .none, |
| 1449 | }); | 1449 | }); |
| 1450 | if (mod.strip) return fi; | 1450 | if (mod.strip) return fi; |
| 1451 | const unit = dwarf.getUnit(mod).get(dwarf); | 1451 | const unit = dwarf.getUnit(mod).get(dwarf); |
| 1452 | func_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( | 1452 | func_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( |
| 1453 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ | 1453 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ |
| 1454 | .enable_next_moved = true, | 1454 | .enable_next_moved = true, |
| 1455 | }) catch |err| switch (err) { | 1455 | }) catch |err| switch (err) { |
| 1456 | else => |e| return e, | 1456 | else => |e| return e, |
| 1457 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ | 1457 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 1458 | elf.mf.io_err.?, | 1458 | elf.mf.io_err.?, |
| 1459 | }), | 1459 | }), |
| 1460 | }, | 1460 | }, |
| 1461 | .{ .func_debug_info = fi }, | 1461 | .{ .func_debug_info = fi }, |
| 1462 | )); | 1462 | )); |
| | 1463 | } else unreachable; |
| 1463 | return fi; | 1464 | return fi; |
| 1464 | } | 1465 | } |
| 1465 | pub fn getFuncIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Func.Index { | 1466 | pub fn getFuncIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Func.Index { |
| ... | @@ -1530,24 +1531,26 @@ pub fn getDecl( | ... | @@ -1530,24 +1531,26 @@ pub fn getDecl( |
| 1530 | const di: Decl.Index = @fromBackingInt(@intCast(decl_gop.index)); | 1531 | const di: Decl.Index = @fromBackingInt(@intCast(decl_gop.index)); |
| 1531 | if (decl_gop.value_ptr.debug_info_ni.unwrap()) |debug_info_ni| return debug_info_ni; | 1532 | if (decl_gop.value_ptr.debug_info_ni.unwrap()) |debug_info_ni| return debug_info_ni; |
| 1532 | dwarf.pending_decl = .{ .di = di, .instance_val = instance_val }; | 1533 | dwarf.pending_decl = .{ .di = di, .instance_val = instance_val }; |
| 1533 | const elf = dwarf.lf.cast(.elf2).?; | 1534 | const debug_info_ni = if (dwarf.lf.cast(.elf2)) |elf| debug_info_ni: { |
| 1534 | try elf.nodes.ensureUnusedCapacity(gpa, 1); | 1535 | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| 1535 | try elf.dwarf_decls.putNoClobber(gpa, di, .{ | 1536 | try elf.dwarf_decls.putNoClobber(gpa, di, .{ |
| 1536 | .debug_info_first_target_reloc = .none, | 1537 | .debug_info_first_target_reloc = .none, |
| 1537 | .debug_info_first_node_reloc = .none, | 1538 | .debug_info_first_node_reloc = .none, |
| 1538 | }); | 1539 | }); |
| 1539 | const unit = dwarf.getUnit(zcu.fileByIndex(di.srcInst(dwarf).resolveFile(ip)).mod.?).get(dwarf); | 1540 | const unit = dwarf.getUnit(zcu.fileByIndex(di.srcInst(dwarf).resolveFile(ip)).mod.?).get(dwarf); |
| 1540 | const debug_info_ni = elf.addNodeAssumeCapacity( | 1541 | const debug_info_ni = elf.addNodeAssumeCapacity( |
| 1541 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ | 1542 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ |
| 1542 | .enable_next_moved = true, | 1543 | .enable_next_moved = true, |
| 1543 | }) catch |err| switch (err) { | 1544 | }) catch |err| switch (err) { |
| 1544 | else => |e| return e, | 1545 | else => |e| return e, |
| 1545 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ | 1546 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 1546 | elf.mf.io_err.?, | 1547 | elf.mf.io_err.?, |
| 1547 | }), | 1548 | }), |
| 1548 | }, | 1549 | }, |
| 1549 | .{ .decl_debug_info = di }, | 1550 | .{ .decl_debug_info = di }, |
| 1550 | ); | 1551 | ); |
| | 1552 | break :debug_info_ni debug_info_ni; |
| | 1553 | } else unreachable; |
| 1551 | decl_gop.value_ptr.debug_info_ni = .wrap(debug_info_ni); | 1554 | decl_gop.value_ptr.debug_info_ni = .wrap(debug_info_ni); |
| 1552 | return debug_info_ni; | 1555 | return debug_info_ni; |
| 1553 | } | 1556 | } |
| ... | @@ -2428,13 +2431,12 @@ fn updateConstInner( | ... | @@ -2428,13 +2431,12 @@ fn updateConstInner( |
| 2428 | }, | 2431 | }, |
| 2429 | .struct_type => { | 2432 | .struct_type => { |
| 2430 | const loaded_struct = ip.loadStructType(val); | 2433 | const loaded_struct = ip.loadStructType(val); |
| 2431 | const zfi = loaded_struct.zir_index.resolveFile(ip); | 2434 | const src_inst = loaded_struct.zir_index.resolveFull(ip).?; |
| 2432 | const zf = zcu.fileByIndex(zfi); | 2435 | const zf = zcu.fileByIndex(src_inst.file); |
| 2433 | const src_inst = loaded_struct.zir_index.resolve(ip); | 2436 | if (src_inst.inst == .main_struct_inst) { |
| 2434 | if (src_inst == .main_struct_inst) { | | |
| 2435 | assert(loaded_struct.captures.len == 0); | 2437 | assert(loaded_struct.captures.len == 0); |
| 2436 | const ui = dwarf.getUnit(zf.mod.?); | 2438 | const ui = dwarf.getUnit(zf.mod.?); |
| 2437 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, zfi); | 2439 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); |
| 2438 | try dwarf.abbrevCode(di_nw, switch (loaded_struct.layout) { | 2440 | try dwarf.abbrevCode(di_nw, switch (loaded_struct.layout) { |
| 2439 | .auto => if (loaded_struct.field_types.len > 0) .file else .empty_file, | 2441 | .auto => if (loaded_struct.field_types.len > 0) .file else .empty_file, |
| 2440 | .@"extern", .@"packed" => unreachable, | 2442 | .@"extern", .@"packed" => unreachable, |
| ... | @@ -2472,7 +2474,7 @@ fn updateConstInner( | ... | @@ -2472,7 +2474,7 @@ fn updateConstInner( |
| 2472 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 2474 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 2473 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); | 2475 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); |
| 2474 | } else { | 2476 | } else { |
| 2475 | const decl = zf.zir.?.getStructDecl(src_inst.?); | 2477 | const decl = zf.zir.?.getStructDecl(src_inst.inst); |
| 2476 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 2478 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 2477 | ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?, | 2479 | ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?, |
| 2478 | ).owner_type); | 2480 | ).owner_type); |
| ... | @@ -2709,6 +2711,7 @@ fn updateConstInner( | ... | @@ -2709,6 +2711,7 @@ fn updateConstInner( |
| 2709 | .none => { | 2711 | .none => { |
| 2710 | const zfi = loaded_enum.zir_index.unwrap().?.resolveFile(ip); | 2712 | const zfi = loaded_enum.zir_index.unwrap().?.resolveFile(ip); |
| 2711 | const zf = zcu.fileByIndex(zfi); | 2713 | const zf = zcu.fileByIndex(zfi); |
| | 2714 | const zir = &zf.zir.?; |
| 2712 | if (loaded_enum.captures.len > 0 or loaded_enum.is_reified) { | 2715 | if (loaded_enum.captures.len > 0 or loaded_enum.is_reified) { |
| 2713 | try dwarf.abbrevCode(di_nw, if (loaded_enum.captures.len > 0 or | 2716 | try dwarf.abbrevCode(di_nw, if (loaded_enum.captures.len > 0 or |
| 2714 | loaded_enum.field_names.len > 0) | 2717 | loaded_enum.field_names.len > 0) |
| ... | @@ -2718,7 +2721,7 @@ fn updateConstInner( | ... | @@ -2718,7 +2721,7 @@ fn updateConstInner( |
| 2718 | try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0); | 2721 | try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0); |
| 2719 | } else if (loaded_enum.name_nav.unwrap()) |name_ni| { | 2722 | } else if (loaded_enum.name_nav.unwrap()) |name_ni| { |
| 2720 | const name_nav = ip.getNav(name_ni); | 2723 | const name_nav = ip.getNav(name_ni); |
| 2721 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); | 2724 | const decl = zir.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 2722 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 2725 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 2723 | name_nav.analysis.?.namespace, | 2726 | name_nav.analysis.?.namespace, |
| 2724 | ).owner_type); | 2727 | ).owner_type); |
| ... | @@ -2732,8 +2735,7 @@ fn updateConstInner( | ... | @@ -2732,8 +2735,7 @@ fn updateConstInner( |
| 2732 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 2735 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 2733 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); | 2736 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); |
| 2734 | } else { | 2737 | } else { |
| 2735 | const decl = | 2738 | const decl = zir.getEnumDecl(loaded_enum.zir_index.unwrap().?.resolve(ip).?); |
| 2736 | zf.zir.?.getEnumDecl(loaded_enum.zir_index.unwrap().?.resolve(ip).?); | | |
| 2737 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 2739 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 2738 | ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?, | 2740 | ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?, |
| 2739 | ).owner_type); | 2741 | ).owner_type); |
| ... | @@ -2756,6 +2758,7 @@ fn updateConstInner( | ... | @@ -2756,6 +2758,7 @@ fn updateConstInner( |
| 2756 | }, | 2758 | }, |
| 2757 | } | 2759 | } |
| 2758 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_enum.int_tag_type)); | 2760 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_enum.int_tag_type)); |
| | 2761 | try dwarf.genCaptures(pt, di_nw, loaded_enum.captures); |
| 2759 | for (0..loaded_enum.field_names.len) |field_index| { | 2762 | for (0..loaded_enum.field_names.len) |field_index| { |
| 2760 | try dwarf.abbrevCode(di_nw, .enum_field); | 2763 | try dwarf.abbrevCode(di_nw, .enum_field); |
| 2761 | try dwarf.enumConstValue(di_w, loaded_enum, field_index); | 2764 | try dwarf.enumConstValue(di_w, loaded_enum, field_index); |
| ... | @@ -2772,10 +2775,10 @@ fn updateConstInner( | ... | @@ -2772,10 +2775,10 @@ fn updateConstInner( |
| 2772 | .opaque_type => return dwarf.updateConstIncompleteInner(pt, di_nw, val), | 2775 | .opaque_type => return dwarf.updateConstIncompleteInner(pt, di_nw, val), |
| 2773 | .spirv_type => unreachable, | 2776 | .spirv_type => unreachable, |
| 2774 | .func_type => |func_type| { | 2777 | .func_type => |func_type| { |
| 2775 | const is_nullary = func_type.param_types.len == 0 and !func_type.is_var_args; | 2778 | const is_empty = func_type.param_types.len == 0 and !func_type.is_var_args; |
| 2776 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); | 2779 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); |
| 2777 | defer zcu.gpa.free(name); | 2780 | defer zcu.gpa.free(name); |
| 2778 | try dwarf.abbrevCode(di_nw, if (is_nullary) .nullary_func_type else .func_type); | 2781 | try dwarf.abbrevCode(di_nw, if (is_empty) .empty_func_type else .func_type); |
| 2779 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 2782 | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| 2780 | const cc: DW.CC = cc: { | 2783 | const cc: DW.CC = cc: { |
| 2781 | if (zcu.getTarget().cCallingConvention()) |cc| { | 2784 | if (zcu.getTarget().cCallingConvention()) |cc| { |
| ... | @@ -2848,16 +2851,14 @@ fn updateConstInner( | ... | @@ -2848,16 +2851,14 @@ fn updateConstInner( |
| 2848 | }; | 2851 | }; |
| 2849 | try di_w.writeByte(@backingInt(cc)); | 2852 | try di_w.writeByte(@backingInt(cc)); |
| 2850 | try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type)); | 2853 | try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type)); |
| 2851 | if (!is_nullary) { | 2854 | for (0..func_type.param_types.len) |param_index| { |
| 2852 | for (0..func_type.param_types.len) |param_index| { | 2855 | try dwarf.abbrevCode(di_nw, .unnamed_param); |
| 2853 | try dwarf.abbrevCode(di_nw, .unnamed_param); | 2856 | try dwarf.refType(pt, di_nw, .fromInterned( |
| 2854 | try dwarf.refType(pt, di_nw, .fromInterned( | 2857 | func_type.param_types.get(ip)[param_index], |
| 2855 | func_type.param_types.get(ip)[param_index], | 2858 | )); |
| 2856 | )); | | |
| 2857 | } | | |
| 2858 | if (func_type.is_var_args) try dwarf.abbrevCode(di_nw, .is_var_args); | | |
| 2859 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | | |
| 2860 | } | 2859 | } |
| | 2860 | if (func_type.is_var_args) try dwarf.abbrevCode(di_nw, .is_var_args); |
| | 2861 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2861 | }, | 2862 | }, |
| 2862 | .error_set_type => |error_set_type| { | 2863 | .error_set_type => |error_set_type| { |
| 2863 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); | 2864 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); |
| ... | @@ -2897,37 +2898,36 @@ fn updateConstInner( | ... | @@ -2897,37 +2898,36 @@ fn updateConstInner( |
| 2897 | | 2898 | |
| 2898 | else => return, | 2899 | else => return, |
| 2899 | .func => |func| { | 2900 | .func => |func| { |
| 2900 | const fn_ty = ip.indexToKey(func.ty).func_type; | 2901 | const func_type = ip.indexToKey(func.ty).func_type; |
| 2901 | const nav = ip.getNav(func.owner_nav); | 2902 | const nav = ip.getNav(func.owner_nav); |
| 2902 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; | 2903 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; |
| 2903 | const zf = zcu.fileByIndex(inst_info.file); | 2904 | const zf = zcu.fileByIndex(inst_info.file); |
| 2904 | const decl = zf.zir.?.getDeclaration(inst_info.inst); | 2905 | const zir = &zf.zir.?; |
| | 2906 | const decl = zir.getDeclaration(inst_info.inst); |
| | 2907 | const empty = func_type.param_types.len == 0 and !func_type.is_var_args; |
| 2905 | const parent_ty: Type = .fromInterned(ip.namespacePtr(nav.analysis.?.namespace).owner_type); | 2908 | const parent_ty: Type = .fromInterned(ip.namespacePtr(nav.analysis.?.namespace).owner_type); |
| 2906 | try dwarf.abbrevCode(di_nw, .decl_func_generic); | 2909 | try dwarf.abbrevCode(di_nw, if (empty) .decl_empty_func_generic else .decl_func_generic); |
| 2907 | try dwarf.refType(pt, di_nw, parent_ty); | 2910 | try dwarf.refType(pt, di_nw, parent_ty); |
| 2908 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 2911 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2909 | try di_w.writeUleb128(decl.src_column + 1); | 2912 | try di_w.writeUleb128(decl.src_column + 1); |
| 2910 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 2913 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 2911 | try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip)); | 2914 | try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip)); |
| 2912 | try dwarf.refType(pt, di_nw, .fromInterned(fn_ty.return_type)); | 2915 | try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type)); |
| 2913 | var param_index: u32 = 0; | 2916 | for ( |
| 2914 | for (zf.zir.?.getParamBody(func.zir_body_inst.resolve(ip).?)) |param_inst| { | 2917 | zir.getParamBody(func.zir_body_inst.resolve(ip).?)[0..func_type.param_types.len], |
| 2915 | switch (zf.zir.?.getParamName(param_inst) orelse break) { | 2918 | func_type.param_types.get(&zcu.intern_pool), |
| | 2919 | ) |param_inst, param_ty| { |
| | 2920 | switch (zir.getParamName(param_inst).?) { |
| 2916 | .empty => try dwarf.abbrevCode(di_nw, .unnamed_param), | 2921 | .empty => try dwarf.abbrevCode(di_nw, .unnamed_param), |
| 2917 | else => |param_name| { | 2922 | else => |param_name| { |
| 2918 | try dwarf.abbrevCode(di_nw, .param); | 2923 | try dwarf.abbrevCode(di_nw, .param); |
| 2919 | try dwarf.strp(&dwarf.debug_str, di_nw, zf.zir.?.nullTerminatedString( | 2924 | try dwarf.strp(&dwarf.debug_str, di_nw, zir.nullTerminatedString(param_name)); |
| 2920 | param_name, | | |
| 2921 | )); | | |
| 2922 | }, | 2925 | }, |
| 2923 | } | 2926 | } |
| 2924 | try dwarf.refType(pt, di_nw, .fromInterned( | 2927 | try dwarf.refType(pt, di_nw, .fromInterned(param_ty)); |
| 2925 | fn_ty.param_types.get(&zcu.intern_pool)[param_index], | | |
| 2926 | )); | | |
| 2927 | param_index += 1; | | |
| 2928 | } | 2928 | } |
| 2929 | if (fn_ty.is_var_args) try dwarf.abbrevCode(di_nw, .is_var_args); | 2929 | if (func_type.is_var_args) try dwarf.abbrevCode(di_nw, .is_var_args); |
| 2930 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | 2930 | if (!empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2931 | }, | 2931 | }, |
| 2932 | | 2932 | |
| 2933 | .memoized_call => unreachable, // not a value | 2933 | .memoized_call => unreachable, // not a value |
| ... | @@ -2988,16 +2988,16 @@ fn updateConstIncompleteInner( | ... | @@ -2988,16 +2988,16 @@ fn updateConstIncompleteInner( |
| 2988 | break :done; | 2988 | break :done; |
| 2989 | }, | 2989 | }, |
| 2990 | else => { | 2990 | else => { |
| 2991 | const data = | 2991 | const zir = &zf.zir.?; |
| 2992 | zf.zir.?.instructions.items(.data)[@backingInt(src_inst.inst)].extended; | 2992 | const data = zir.instructions.items(.data)[@backingInt(src_inst.inst)].extended; |
| 2993 | const src_line, const src_column = src_loc: switch (data.opcode) { | 2993 | const src_line, const src_column = src_loc: switch (data.opcode) { |
| 2994 | else => unreachable, | 2994 | else => unreachable, |
| 2995 | .struct_decl => { | 2995 | .struct_decl => { |
| 2996 | const decl = zf.zir.?.getStructDecl(src_inst.inst); | 2996 | const decl = zir.getStructDecl(src_inst.inst); |
| 2997 | break :src_loc .{ decl.src_line, decl.src_column }; | 2997 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 2998 | }, | 2998 | }, |
| 2999 | .reify_struct => { | 2999 | .reify_struct => { |
| 3000 | const decl = zf.zir.?.extraData( | 3000 | const decl = zir.extraData( |
| 3001 | std.zig.Zir.Inst.ReifyStruct, | 3001 | std.zig.Zir.Inst.ReifyStruct, |
| 3002 | data.operand, | 3002 | data.operand, |
| 3003 | ).data; | 3003 | ).data; |
| ... | @@ -3025,15 +3025,16 @@ fn updateConstIncompleteInner( | ... | @@ -3025,15 +3025,16 @@ fn updateConstIncompleteInner( |
| 3025 | break :done; | 3025 | break :done; |
| 3026 | }; | 3026 | }; |
| 3027 | const zf = zcu.fileByIndex(src_inst.file); | 3027 | const zf = zcu.fileByIndex(src_inst.file); |
| 3028 | const data = zf.zir.?.instructions.items(.data)[@backingInt(src_inst.inst)].extended; | 3028 | const zir = &zf.zir.?; |
| | 3029 | const data = zir.instructions.items(.data)[@backingInt(src_inst.inst)].extended; |
| 3029 | const src_line, const src_column = src_loc: switch (data.opcode) { | 3030 | const src_line, const src_column = src_loc: switch (data.opcode) { |
| 3030 | else => unreachable, | 3031 | else => unreachable, |
| 3031 | .union_decl => { | 3032 | .union_decl => { |
| 3032 | const decl = zf.zir.?.getUnionDecl(src_inst.inst); | 3033 | const decl = zir.getUnionDecl(src_inst.inst); |
| 3033 | break :src_loc .{ decl.src_line, decl.src_column }; | 3034 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 3034 | }, | 3035 | }, |
| 3035 | .reify_union => { | 3036 | .reify_union => { |
| 3036 | const decl = zf.zir.?.extraData(std.zig.Zir.Inst.ReifyUnion, data.operand).data; | 3037 | const decl = zir.extraData(std.zig.Zir.Inst.ReifyUnion, data.operand).data; |
| 3037 | break :src_loc .{ decl.src_line, decl.src_column }; | 3038 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 3038 | }, | 3039 | }, |
| 3039 | }; | 3040 | }; |
| ... | @@ -3062,15 +3063,16 @@ fn updateConstIncompleteInner( | ... | @@ -3062,15 +3063,16 @@ fn updateConstIncompleteInner( |
| 3062 | break :done; | 3063 | break :done; |
| 3063 | }; | 3064 | }; |
| 3064 | const zf = zcu.fileByIndex(src_inst.file); | 3065 | const zf = zcu.fileByIndex(src_inst.file); |
| 3065 | const data = zf.zir.?.instructions.items(.data)[@backingInt(src_inst.inst)].extended; | 3066 | const zir = &zf.zir.?; |
| | 3067 | const data = zir.instructions.items(.data)[@backingInt(src_inst.inst)].extended; |
| 3066 | const src_line, const src_column = src_loc: switch (data.opcode) { | 3068 | const src_line, const src_column = src_loc: switch (data.opcode) { |
| 3067 | else => unreachable, | 3069 | else => unreachable, |
| 3068 | .enum_decl => { | 3070 | .enum_decl => { |
| 3069 | const decl = zf.zir.?.getEnumDecl(src_inst.inst); | 3071 | const decl = zir.getEnumDecl(src_inst.inst); |
| 3070 | break :src_loc .{ decl.src_line, decl.src_column }; | 3072 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 3071 | }, | 3073 | }, |
| 3072 | .reify_enum => { | 3074 | .reify_enum => { |
| 3073 | const decl = zf.zir.?.extraData(std.zig.Zir.Inst.ReifyEnum, data.operand).data; | 3075 | const decl = zir.extraData(std.zig.Zir.Inst.ReifyEnum, data.operand).data; |
| 3074 | break :src_loc .{ decl.src_line, decl.src_column }; | 3076 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 3075 | }, | 3077 | }, |
| 3076 | }; | 3078 | }; |
| ... | @@ -3251,18 +3253,19 @@ fn genDeclInner( | ... | @@ -3251,18 +3253,19 @@ fn genDeclInner( |
| 3251 | break :done; | 3253 | break :done; |
| 3252 | }; | 3254 | }; |
| 3253 | const zf = zcu.fileByIndex(src_inst.file); | 3255 | const zf = zcu.fileByIndex(src_inst.file); |
| 3254 | const inst = zf.zir.?.instructions.get(@backingInt(src_inst.inst)); | 3256 | const zir = &zf.zir.?; |
| | 3257 | const inst = zir.instructions.get(@backingInt(src_inst.inst)); |
| 3255 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { | 3258 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { |
| 3256 | else => unreachable, | 3259 | else => unreachable, |
| 3257 | .struct_init, .struct_init_ref => { | 3260 | .struct_init, .struct_init_ref => { |
| 3258 | const decl = zf.zir.?.extraData( | 3261 | const decl = zir.extraData( |
| 3259 | std.zig.Zir.Inst.StructInit, | 3262 | std.zig.Zir.Inst.StructInit, |
| 3260 | inst.data.pl_node.payload_index, | 3263 | inst.data.pl_node.payload_index, |
| 3261 | ).data; | 3264 | ).data; |
| 3262 | break :decl .{ decl.src_line, decl.src_column, &.{} }; | 3265 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| 3263 | }, | 3266 | }, |
| 3264 | .struct_init_anon => { | 3267 | .struct_init_anon => { |
| 3265 | const decl = zf.zir.?.extraData( | 3268 | const decl = zir.extraData( |
| 3266 | std.zig.Zir.Inst.StructInitAnon, | 3269 | std.zig.Zir.Inst.StructInitAnon, |
| 3267 | inst.data.pl_node.payload_index, | 3270 | inst.data.pl_node.payload_index, |
| 3268 | ).data; | 3271 | ).data; |
| ... | @@ -3271,11 +3274,11 @@ fn genDeclInner( | ... | @@ -3271,11 +3274,11 @@ fn genDeclInner( |
| 3271 | .extended => switch (inst.data.extended.opcode) { | 3274 | .extended => switch (inst.data.extended.opcode) { |
| 3272 | else => unreachable, | 3275 | else => unreachable, |
| 3273 | .struct_decl => { | 3276 | .struct_decl => { |
| 3274 | const decl = zf.zir.?.getStructDecl(src_inst.inst); | 3277 | const decl = zir.getStructDecl(src_inst.inst); |
| 3275 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; | 3278 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; |
| 3276 | }, | 3279 | }, |
| 3277 | .reify_struct => { | 3280 | .reify_struct => { |
| 3278 | const decl = zf.zir.?.extraData( | 3281 | const decl = zir.extraData( |
| 3279 | std.zig.Zir.Inst.ReifyStruct, | 3282 | std.zig.Zir.Inst.ReifyStruct, |
| 3280 | inst.data.extended.operand, | 3283 | inst.data.extended.operand, |
| 3281 | ).data; | 3284 | ).data; |
| ... | @@ -3302,17 +3305,18 @@ fn genDeclInner( | ... | @@ -3302,17 +3305,18 @@ fn genDeclInner( |
| 3302 | break :done; | 3305 | break :done; |
| 3303 | }; | 3306 | }; |
| 3304 | const zf = zcu.fileByIndex(src_inst.file); | 3307 | const zf = zcu.fileByIndex(src_inst.file); |
| 3305 | const inst = zf.zir.?.instructions.get(@backingInt(src_inst.inst)); | 3308 | const zir = &zf.zir.?; |
| | 3309 | const inst = zir.instructions.get(@backingInt(src_inst.inst)); |
| 3306 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { | 3310 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { |
| 3307 | else => unreachable, | 3311 | else => unreachable, |
| 3308 | .extended => switch (inst.data.extended.opcode) { | 3312 | .extended => switch (inst.data.extended.opcode) { |
| 3309 | else => unreachable, | 3313 | else => unreachable, |
| 3310 | .union_decl => { | 3314 | .union_decl => { |
| 3311 | const decl = zf.zir.?.getUnionDecl(src_inst.inst); | 3315 | const decl = zir.getUnionDecl(src_inst.inst); |
| 3312 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; | 3316 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; |
| 3313 | }, | 3317 | }, |
| 3314 | .reify_union => { | 3318 | .reify_union => { |
| 3315 | const decl = zf.zir.?.extraData( | 3319 | const decl = zir.extraData( |
| 3316 | std.zig.Zir.Inst.ReifyUnion, | 3320 | std.zig.Zir.Inst.ReifyUnion, |
| 3317 | inst.data.extended.operand, | 3321 | inst.data.extended.operand, |
| 3318 | ).data; | 3322 | ).data; |
| ... | @@ -3339,17 +3343,18 @@ fn genDeclInner( | ... | @@ -3339,17 +3343,18 @@ fn genDeclInner( |
| 3339 | break :done; | 3343 | break :done; |
| 3340 | }; | 3344 | }; |
| 3341 | const zf = zcu.fileByIndex(src_inst.file); | 3345 | const zf = zcu.fileByIndex(src_inst.file); |
| 3342 | const inst = zf.zir.?.instructions.get(@backingInt(src_inst.inst)); | 3346 | const zir = &zf.zir.?; |
| | 3347 | const inst = zir.instructions.get(@backingInt(src_inst.inst)); |
| 3343 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { | 3348 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { |
| 3344 | else => unreachable, | 3349 | else => unreachable, |
| 3345 | .extended => switch (inst.data.extended.opcode) { | 3350 | .extended => switch (inst.data.extended.opcode) { |
| 3346 | else => unreachable, | 3351 | else => unreachable, |
| 3347 | .enum_decl => { | 3352 | .enum_decl => { |
| 3348 | const decl = zf.zir.?.getEnumDecl(src_inst.inst); | 3353 | const decl = zir.getEnumDecl(src_inst.inst); |
| 3349 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; | 3354 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; |
| 3350 | }, | 3355 | }, |
| 3351 | .reify_enum => { | 3356 | .reify_enum => { |
| 3352 | const decl = zf.zir.?.extraData( | 3357 | const decl = zir.extraData( |
| 3353 | std.zig.Zir.Inst.ReifyEnum, | 3358 | std.zig.Zir.Inst.ReifyEnum, |
| 3354 | inst.data.extended.operand, | 3359 | inst.data.extended.operand, |
| 3355 | ).data; | 3360 | ).data; |
| ... | @@ -3390,9 +3395,10 @@ fn genDeclInner( | ... | @@ -3390,9 +3395,10 @@ fn genDeclInner( |
| 3390 | }; | 3395 | }; |
| 3391 | }, | 3396 | }, |
| 3392 | }; | 3397 | }; |
| | 3398 | const zir = &zf.zir.?; |
| 3393 | if (maybe_name_nav.unwrap()) |name_ni| { | 3399 | if (maybe_name_nav.unwrap()) |name_ni| { |
| 3394 | const name_nav = ip.getNav(name_ni); | 3400 | const name_nav = ip.getNav(name_ni); |
| 3395 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); | 3401 | const decl = zir.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 3396 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 3402 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 3397 | name_nav.analysis.?.namespace, | 3403 | name_nav.analysis.?.namespace, |
| 3398 | ).owner_type); | 3404 | ).owner_type); |
| ... | @@ -3434,12 +3440,11 @@ fn genDeclInner( | ... | @@ -3434,12 +3440,11 @@ fn genDeclInner( |
| 3434 | .@"comptime", .runtime, .nav_val => try dwarf.strp( | 3440 | .@"comptime", .runtime, .nav_val => try dwarf.strp( |
| 3435 | &dwarf.debug_str, | 3441 | &dwarf.debug_str, |
| 3436 | di_nw, | 3442 | di_nw, |
| 3437 | zf.zir.?.nullTerminatedString(capture_name), | 3443 | zir.nullTerminatedString(capture_name), |
| 3438 | ), | 3444 | ), |
| 3439 | .nav_ref => { | 3445 | .nav_ref => { |
| 3440 | const capture_name_slice = try zcu.gpa.print("&{s}", .{ | 3446 | const capture_name_slice = |
| 3441 | zf.zir.?.nullTerminatedString(capture_name), | 3447 | try zcu.gpa.print("&{s}", .{zir.nullTerminatedString(capture_name)}); |
| 3442 | }); | | |
| 3443 | defer zcu.gpa.free(capture_name_slice); | 3448 | defer zcu.gpa.free(capture_name_slice); |
| 3444 | try dwarf.strp(&dwarf.debug_str, di_nw, capture_name_slice); | 3449 | try dwarf.strp(&dwarf.debug_str, di_nw, capture_name_slice); |
| 3445 | }, | 3450 | }, |
| ... | @@ -3585,13 +3590,9 @@ fn blockConst( | ... | @@ -3585,13 +3590,9 @@ fn blockConst( |
| 3585 | const size = ty.abiSize(pt.zcu); | 3590 | const size = ty.abiSize(pt.zcu); |
| 3586 | try nw.interface.writeUleb128(size); | 3591 | try nw.interface.writeUleb128(size); |
| 3587 | const start = nw.interface.end; | 3592 | const start = nw.interface.end; |
| 3588 | if (size > 0) try codegen.generateSymbol( | 3593 | if (size > 0) try codegen.generateSymbol(dwarf.lf, pt, val, &nw.interface, .{ |
| 3589 | dwarf.lf, | 3594 | .atom_index = @bitCast(nw.ni), |
| 3590 | pt, | 3595 | }); |
| 3591 | val, | | |
| 3592 | &nw.interface, | | |
| 3593 | .{ .atom_index = @bitCast(nw.ni) }, | | |
| 3594 | ); | | |
| 3595 | assert(start + size == nw.interface.end); | 3596 | assert(start + size == nw.interface.end); |
| 3596 | } | 3597 | } |
| 3597 | | 3598 | |
| ... | @@ -3782,11 +3783,11 @@ pub const AbbrevCode = enum { | ... | @@ -3782,11 +3783,11 @@ pub const AbbrevCode = enum { |
| 3782 | decl_const_runtime_bits, | 3783 | decl_const_runtime_bits, |
| 3783 | decl_const_comptime_state, | 3784 | decl_const_comptime_state, |
| 3784 | decl_const_runtime_bits_comptime_state, | 3785 | decl_const_runtime_bits_comptime_state, |
| 3785 | decl_nullary_func, | 3786 | decl_empty_func, |
| 3786 | decl_func, | 3787 | decl_func, |
| 3787 | decl_nullary_func_generic, | 3788 | decl_empty_func_generic, |
| 3788 | decl_func_generic, | 3789 | decl_func_generic, |
| 3789 | decl_extern_nullary_func, | 3790 | decl_extern_empty_func, |
| 3790 | decl_extern_func, | 3791 | decl_extern_func, |
| 3791 | decl_specification_empty_struct, | 3792 | decl_specification_empty_struct, |
| 3792 | decl_specification_struct, | 3793 | decl_specification_struct, |
| ... | @@ -3823,11 +3824,11 @@ pub const AbbrevCode = enum { | ... | @@ -3823,11 +3824,11 @@ pub const AbbrevCode = enum { |
| 3823 | decl_instance_const_runtime_bits, | 3824 | decl_instance_const_runtime_bits, |
| 3824 | decl_instance_const_comptime_state, | 3825 | decl_instance_const_comptime_state, |
| 3825 | decl_instance_const_runtime_bits_comptime_state, | 3826 | decl_instance_const_runtime_bits_comptime_state, |
| 3826 | decl_instance_nullary_func, | 3827 | decl_instance_empty_func, |
| 3827 | decl_instance_func, | 3828 | decl_instance_func, |
| 3828 | decl_instance_nullary_func_generic, | 3829 | decl_instance_empty_func_generic, |
| 3829 | decl_instance_func_generic, | 3830 | decl_instance_func_generic, |
| 3830 | decl_instance_extern_nullary_func, | 3831 | decl_instance_extern_empty_func, |
| 3831 | decl_instance_extern_func, | 3832 | decl_instance_extern_func, |
| 3832 | // the rest are unrestricted other than empty variants must not be longer | 3833 | // the rest are unrestricted other than empty variants must not be longer |
| 3833 | // than the non-empty variant, and so should appear first | 3834 | // than the non-empty variant, and so should appear first |
| ... | @@ -3865,7 +3866,7 @@ pub const AbbrevCode = enum { | ... | @@ -3865,7 +3866,7 @@ pub const AbbrevCode = enum { |
| 3865 | vector_type, | 3866 | vector_type, |
| 3866 | array_index, | 3867 | array_index, |
| 3867 | array_len, | 3868 | array_len, |
| 3868 | nullary_func_type, | 3869 | empty_func_type, |
| 3869 | func_type, | 3870 | func_type, |
| 3870 | param, | 3871 | param, |
| 3871 | unnamed_param, | 3872 | unnamed_param, |
| ... | @@ -3882,7 +3883,7 @@ pub const AbbrevCode = enum { | ... | @@ -3882,7 +3883,7 @@ pub const AbbrevCode = enum { |
| 3882 | comptime_capture_fully_comptime, | 3883 | comptime_capture_fully_comptime, |
| 3883 | runtime_capture, | 3884 | runtime_capture, |
| 3884 | nav_capture, | 3885 | nav_capture, |
| 3885 | builtin_extern_nullary_func, | 3886 | builtin_extern_empty_func, |
| 3886 | builtin_extern_func, | 3887 | builtin_extern_func, |
| 3887 | builtin_extern_var, | 3888 | builtin_extern_var, |
| 3888 | empty_block, | 3889 | empty_block, |
| ... | @@ -4216,7 +4217,7 @@ pub const AbbrevCode = enum { | ... | @@ -4216,7 +4217,7 @@ pub const AbbrevCode = enum { |
| 4216 | .{ .ZIG_comptime_value, .ref_addr }, | 4217 | .{ .ZIG_comptime_value, .ref_addr }, |
| 4217 | }, | 4218 | }, |
| 4218 | }, | 4219 | }, |
| 4219 | .decl_nullary_func = .{ | 4220 | .decl_empty_func = .{ |
| 4220 | .tag = .subprogram, | 4221 | .tag = .subprogram, |
| 4221 | .attrs = decl_attrs ++ .{ | 4222 | .attrs = decl_attrs ++ .{ |
| 4222 | .{ .linkage_name, .strp }, | 4223 | .{ .linkage_name, .strp }, |
| ... | @@ -4241,11 +4242,10 @@ pub const AbbrevCode = enum { | ... | @@ -4241,11 +4242,10 @@ pub const AbbrevCode = enum { |
| 4241 | .{ .noreturn, .flag }, | 4242 | .{ .noreturn, .flag }, |
| 4242 | }, | 4243 | }, |
| 4243 | }, | 4244 | }, |
| 4244 | .decl_nullary_func_generic = .{ | 4245 | .decl_empty_func_generic = .{ |
| 4245 | .tag = .subprogram, | 4246 | .tag = .subprogram, |
| 4246 | .attrs = decl_attrs ++ .{ | 4247 | .attrs = decl_attrs ++ .{ |
| 4247 | .{ .type, .ref_addr }, | 4248 | .{ .type, .ref_addr }, |
| 4248 | .{ .noreturn, .flag }, | | |
| 4249 | }, | 4249 | }, |
| 4250 | }, | 4250 | }, |
| 4251 | .decl_func_generic = .{ | 4251 | .decl_func_generic = .{ |
| ... | @@ -4255,7 +4255,7 @@ pub const AbbrevCode = enum { | ... | @@ -4255,7 +4255,7 @@ pub const AbbrevCode = enum { |
| 4255 | .{ .type, .ref_addr }, | 4255 | .{ .type, .ref_addr }, |
| 4256 | }, | 4256 | }, |
| 4257 | }, | 4257 | }, |
| 4258 | .decl_extern_nullary_func = .{ | 4258 | .decl_extern_empty_func = .{ |
| 4259 | .tag = .subprogram, | 4259 | .tag = .subprogram, |
| 4260 | .attrs = decl_attrs ++ .{ | 4260 | .attrs = decl_attrs ++ .{ |
| 4261 | .{ .linkage_name, .strp }, | 4261 | .{ .linkage_name, .strp }, |
| ... | @@ -4486,7 +4486,7 @@ pub const AbbrevCode = enum { | ... | @@ -4486,7 +4486,7 @@ pub const AbbrevCode = enum { |
| 4486 | .{ .ZIG_comptime_value, .ref_addr }, | 4486 | .{ .ZIG_comptime_value, .ref_addr }, |
| 4487 | }, | 4487 | }, |
| 4488 | }, | 4488 | }, |
| 4489 | .decl_instance_nullary_func = .{ | 4489 | .decl_instance_empty_func = .{ |
| 4490 | .tag = .subprogram, | 4490 | .tag = .subprogram, |
| 4491 | .attrs = decl_instance_attrs ++ .{ | 4491 | .attrs = decl_instance_attrs ++ .{ |
| 4492 | .{ .linkage_name, .strp }, | 4492 | .{ .linkage_name, .strp }, |
| ... | @@ -4511,7 +4511,7 @@ pub const AbbrevCode = enum { | ... | @@ -4511,7 +4511,7 @@ pub const AbbrevCode = enum { |
| 4511 | .{ .noreturn, .flag }, | 4511 | .{ .noreturn, .flag }, |
| 4512 | }, | 4512 | }, |
| 4513 | }, | 4513 | }, |
| 4514 | .decl_instance_nullary_func_generic = .{ | 4514 | .decl_instance_empty_func_generic = .{ |
| 4515 | .tag = .subprogram, | 4515 | .tag = .subprogram, |
| 4516 | .attrs = decl_instance_attrs ++ .{ | 4516 | .attrs = decl_instance_attrs ++ .{ |
| 4517 | .{ .type, .ref_addr }, | 4517 | .{ .type, .ref_addr }, |
| ... | @@ -4524,7 +4524,7 @@ pub const AbbrevCode = enum { | ... | @@ -4524,7 +4524,7 @@ pub const AbbrevCode = enum { |
| 4524 | .{ .type, .ref_addr }, | 4524 | .{ .type, .ref_addr }, |
| 4525 | }, | 4525 | }, |
| 4526 | }, | 4526 | }, |
| 4527 | .decl_instance_extern_nullary_func = .{ | 4527 | .decl_instance_extern_empty_func = .{ |
| 4528 | .tag = .subprogram, | 4528 | .tag = .subprogram, |
| 4529 | .attrs = decl_instance_attrs ++ .{ | 4529 | .attrs = decl_instance_attrs ++ .{ |
| 4530 | .{ .linkage_name, .strp }, | 4530 | .{ .linkage_name, .strp }, |
| ... | @@ -4827,7 +4827,7 @@ pub const AbbrevCode = enum { | ... | @@ -4827,7 +4827,7 @@ pub const AbbrevCode = enum { |
| 4827 | .{ .count, .udata }, | 4827 | .{ .count, .udata }, |
| 4828 | }, | 4828 | }, |
| 4829 | }, | 4829 | }, |
| 4830 | .nullary_func_type = .{ | 4830 | .empty_func_type = .{ |
| 4831 | .tag = .subroutine_type, | 4831 | .tag = .subroutine_type, |
| 4832 | .attrs = &.{ | 4832 | .attrs = &.{ |
| 4833 | .{ .name, .strp }, | 4833 | .{ .name, .strp }, |
| ... | @@ -4946,7 +4946,7 @@ pub const AbbrevCode = enum { | ... | @@ -4946,7 +4946,7 @@ pub const AbbrevCode = enum { |
| 4946 | .{ .location, .exprloc }, | 4946 | .{ .location, .exprloc }, |
| 4947 | }, | 4947 | }, |
| 4948 | }, | 4948 | }, |
| 4949 | .builtin_extern_nullary_func = .{ | 4949 | .builtin_extern_empty_func = .{ |
| 4950 | .tag = .subprogram, | 4950 | .tag = .subprogram, |
| 4951 | .attrs = &.{ | 4951 | .attrs = &.{ |
| 4952 | .{ .ZIG_parent, .ref_addr }, | 4952 | .{ .ZIG_parent, .ref_addr }, |