| ... | ... | @@ -86,6 +86,9 @@ next_stack_offset: u32 = 0, |
| 86 | 86 | /// Debug field, used to find bugs in the compiler. |
| 87 | 87 | air_bookkeeping: @TypeOf(air_bookkeeping_init) = air_bookkeeping_init, |
| 88 | 88 | |
| 89 | /// For mir debug info, maps a mir index to a air index |
| 90 | mir_to_air_map: if (builtin.mode == .Debug) std.AutoHashMap(Mir.Inst.Index, Air.Inst.Index) else void, |
| 91 | |
| 89 | 92 | const air_bookkeeping_init = if (std.debug.runtime_safety) @as(usize, 0) else {}; |
| 90 | 93 | |
| 91 | 94 | pub const MCValue = union(enum) { |
| ... | ... | @@ -272,12 +275,14 @@ pub fn generate( |
| 272 | 275 | .stack_align = undefined, |
| 273 | 276 | .end_di_line = module_fn.rbrace_line, |
| 274 | 277 | .end_di_column = module_fn.rbrace_column, |
| 278 | .mir_to_air_map = if (builtin.mode == .Debug) std.AutoHashMap(Mir.Inst.Index, Air.Inst.Index).init(bin_file.allocator) else {}, |
| 275 | 279 | }; |
| 276 | 280 | defer function.stack.deinit(bin_file.allocator); |
| 277 | 281 | defer function.blocks.deinit(bin_file.allocator); |
| 278 | 282 | defer function.exitlude_jump_relocs.deinit(bin_file.allocator); |
| 279 | 283 | defer function.mir_instructions.deinit(bin_file.allocator); |
| 280 | 284 | defer function.mir_extra.deinit(bin_file.allocator); |
| 285 | defer if (builtin.mode == .Debug) function.mir_to_air_map.deinit(); |
| 281 | 286 | |
| 282 | 287 | var call_info = function.resolveCallingConventionValues(fn_type) catch |err| switch (err) { |
| 283 | 288 | error.CodegenFail => return FnResult{ .fail = function.err_msg.? }, |
| ... | ... | @@ -323,8 +328,8 @@ pub fn generate( |
| 323 | 328 | const w = std.io.getStdErr().writer(); |
| 324 | 329 | w.print("# Begin Function MIR: {s}:\n", .{module_fn.owner_decl.name}) catch {}; |
| 325 | 330 | const print = @import("./PrintMir.zig"){ .mir = mir }; |
| 326 | | print.printMir(w) catch {}; // we don't care if the debug printing fails |
| 327 | | w.print("# End Function MIR: {s}:\n\n", .{module_fn.owner_decl.name}) catch {}; |
| 331 | print.printMir(w, function.mir_to_air_map, air) catch {}; // we don't care if the debug printing fails |
| 332 | w.print("# End Function MIR: {s}\n\n", .{module_fn.owner_decl.name}) catch {}; |
| 328 | 333 | } |
| 329 | 334 | |
| 330 | 335 | if (function.err_msg) |em| { |
| ... | ... | @@ -525,6 +530,9 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 525 | 530 | for (body) |inst| { |
| 526 | 531 | const old_air_bookkeeping = self.air_bookkeeping; |
| 527 | 532 | try self.ensureProcessDeathCapacity(Liveness.bpi); |
| 533 | if (builtin.mode == .Debug) { |
| 534 | try self.mir_to_air_map.put(@intCast(u32, self.mir_instructions.len), inst); |
| 535 | } |
| 528 | 536 | |
| 529 | 537 | switch (air_tags[inst]) { |
| 530 | 538 | // zig fmt: off |