| ... | @@ -8026,7 +8026,10 @@ pub const Metadata = enum(u32) { | ... | @@ -8026,7 +8026,10 @@ pub const Metadata = enum(u32) { |
| 8026 | const Formatter = struct { | 8026 | const Formatter = struct { |
| 8027 | builder: *Builder, | 8027 | builder: *Builder, |
| 8028 | need_comma: bool, | 8028 | need_comma: bool, |
| 8029 | map: std.AutoArrayHashMapUnmanaged(Metadata, void) = .{}, | 8029 | map: std.AutoArrayHashMapUnmanaged(union(enum) { |
| | 8030 | metadata: Metadata, |
| | 8031 | debug_location: DebugLocation.Location, |
| | 8032 | }, void) = .{}, |
| 8030 | | 8033 | |
| 8031 | const FormatData = struct { | 8034 | const FormatData = struct { |
| 8032 | formatter: *Formatter, | 8035 | formatter: *Formatter, |
| ... | @@ -8214,7 +8217,7 @@ pub const Metadata = enum(u32) { | ... | @@ -8214,7 +8217,7 @@ pub const Metadata = enum(u32) { |
| 8214 | .expression, .constant => return .{ .@"inline" = unwrapped_metadata }, | 8217 | .expression, .constant => return .{ .@"inline" = unwrapped_metadata }, |
| 8215 | else => { | 8218 | else => { |
| 8216 | assert(!tag.isInline()); | 8219 | assert(!tag.isInline()); |
| 8217 | const gop = try formatter.map.getOrPutValue(builder.gpa, unwrapped_metadata, {}); | 8220 | const gop = try formatter.map.getOrPut(builder.gpa, .{ .metadata = unwrapped_metadata }); |
| 8218 | return .{ .index = @intCast(gop.index) }; | 8221 | return .{ .index = @intCast(gop.index) }; |
| 8219 | }, | 8222 | }, |
| 8220 | } | 8223 | } |
| ... | @@ -9433,12 +9436,19 @@ pub fn printUnbuffered( | ... | @@ -9433,12 +9436,19 @@ pub fn printUnbuffered( |
| 9433 | if (function.instructions.len > 0) { | 9436 | if (function.instructions.len > 0) { |
| 9434 | var block_incoming_len: u32 = undefined; | 9437 | var block_incoming_len: u32 = undefined; |
| 9435 | try writer.writeAll(" {\n"); | 9438 | try writer.writeAll(" {\n"); |
| 9436 | var dbg: Metadata = .none; | 9439 | var maybe_dbg_index: ?u32 = null; |
| 9437 | for (params_len..function.instructions.len) |instruction_i| { | 9440 | for (params_len..function.instructions.len) |instruction_i| { |
| 9438 | const instruction_index: Function.Instruction.Index = @enumFromInt(instruction_i); | 9441 | const instruction_index: Function.Instruction.Index = @enumFromInt(instruction_i); |
| 9439 | const instruction = function.instructions.get(@intFromEnum(instruction_index)); | 9442 | const instruction = function.instructions.get(@intFromEnum(instruction_index)); |
| 9440 | if (function.debug_locations.get(instruction_index)) |debug_location| | 9443 | if (function.debug_locations.get(instruction_index)) |debug_location| switch (debug_location) { |
| 9441 | dbg = debug_location; | 9444 | .no_location => maybe_dbg_index = null, |
| | 9445 | .location => |location| { |
| | 9446 | const gop = try metadata_formatter.map.getOrPut(self.gpa, .{ |
| | 9447 | .debug_location = location, |
| | 9448 | }); |
| | 9449 | maybe_dbg_index = @intCast(gop.index); |
| | 9450 | }, |
| | 9451 | }; |
| 9442 | switch (instruction.tag) { | 9452 | switch (instruction.tag) { |
| 9443 | .add, | 9453 | .add, |
| 9444 | .@"add nsw", | 9454 | .@"add nsw", |
| ... | @@ -9870,9 +9880,10 @@ pub fn printUnbuffered( | ... | @@ -9870,9 +9880,10 @@ pub fn printUnbuffered( |
| 9870 | }); | 9880 | }); |
| 9871 | }, | 9881 | }, |
| 9872 | } | 9882 | } |
| 9873 | metadata_formatter.need_comma = true; | 9883 | |
| 9874 | defer metadata_formatter.need_comma = undefined; | 9884 | if (maybe_dbg_index) |dbg_index| { |
| 9875 | try writer.print("{}\n", .{try metadata_formatter.fmt("!dbg ", dbg)}); | 9885 | try writer.print(", !dbg !{}\n", .{dbg_index}); |
| | 9886 | } else try writer.writeByte('\n'); |
| 9876 | } | 9887 | } |
| 9877 | try writer.writeByte('}'); | 9888 | try writer.writeByte('}'); |
| 9878 | } | 9889 | } |
| ... | @@ -9908,11 +9919,25 @@ pub fn printUnbuffered( | ... | @@ -9908,11 +9919,25 @@ pub fn printUnbuffered( |
| 9908 | var metadata_index: usize = 0; | 9919 | var metadata_index: usize = 0; |
| 9909 | while (metadata_index < metadata_formatter.map.count()) : (metadata_index += 1) { | 9920 | while (metadata_index < metadata_formatter.map.count()) : (metadata_index += 1) { |
| 9910 | @setEvalBranchQuota(10_000); | 9921 | @setEvalBranchQuota(10_000); |
| 9911 | const metadata_item = | | |
| 9912 | self.metadata_items.get(@intFromEnum(metadata_formatter.map.keys()[metadata_index])); | | |
| 9913 | try writer.print("!{} = ", .{metadata_index}); | 9922 | try writer.print("!{} = ", .{metadata_index}); |
| 9914 | metadata_formatter.need_comma = false; | 9923 | metadata_formatter.need_comma = false; |
| 9915 | defer metadata_formatter.need_comma = undefined; | 9924 | defer metadata_formatter.need_comma = undefined; |
| | 9925 | |
| | 9926 | const key = metadata_formatter.map.keys()[metadata_index]; |
| | 9927 | const metadata_item = switch (key) { |
| | 9928 | .debug_location => |location| { |
| | 9929 | try metadata_formatter.specialized(.@"!", .DILocation, .{ |
| | 9930 | .line = location.line, |
| | 9931 | .column = location.column, |
| | 9932 | .scope = location.scope, |
| | 9933 | .inlinedAt = location.inlined_at, |
| | 9934 | .isImplicitCode = false, |
| | 9935 | }, writer); |
| | 9936 | continue; |
| | 9937 | }, |
| | 9938 | .metadata => |metadata| self.metadata_items.get(@intFromEnum(metadata)), |
| | 9939 | }; |
| | 9940 | |
| 9916 | switch (metadata_item.tag) { | 9941 | switch (metadata_item.tag) { |
| 9917 | .none, .expression, .constant => unreachable, | 9942 | .none, .expression, .constant => unreachable, |
| 9918 | .file => { | 9943 | .file => { |