| ... | @@ -2460,26 +2460,6 @@ fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2460,26 +2460,6 @@ fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void { |
| 2460 | | 2460 | |
| 2461 | // Common helper functions | 2461 | // Common helper functions |
| 2462 | | 2462 | |
| 2463 | /// Adds a Type to the .debug_info at the current position. The bytes will be populated later, | | |
| 2464 | /// after codegen for this symbol is done. | | |
| 2465 | fn addDbgInfoTypeReloc(self: *Self, ty: Type) !void { | | |
| 2466 | switch (self.debug_output) { | | |
| 2467 | .dwarf => |dw| { | | |
| 2468 | assert(ty.hasRuntimeBits()); | | |
| 2469 | const dbg_info = &dw.dbg_info; | | |
| 2470 | const index = dbg_info.items.len; | | |
| 2471 | try dbg_info.resize(index + 4); // DW.AT.type, DW.FORM.ref4 | | |
| 2472 | const mod = self.bin_file.options.module.?; | | |
| 2473 | const atom = switch (self.bin_file.tag) { | | |
| 2474 | .elf => &mod.declPtr(self.mod_fn.owner_decl).link.elf.dbg_info_atom, | | |
| 2475 | else => unreachable, | | |
| 2476 | }; | | |
| 2477 | try dw.addTypeRelocGlobal(atom, ty, @intCast(u32, index)); | | |
| 2478 | }, | | |
| 2479 | else => {}, | | |
| 2480 | } | | |
| 2481 | } | | |
| 2482 | | | |
| 2483 | fn addInst(self: *Self, inst: Mir.Inst) error{OutOfMemory}!Mir.Inst.Index { | 2463 | fn addInst(self: *Self, inst: Mir.Inst) error{OutOfMemory}!Mir.Inst.Index { |
| 2484 | const gpa = self.gpa; | 2464 | const gpa = self.gpa; |
| 2485 | try self.mir_instructions.ensureUnusedCapacity(gpa, 1); | 2465 | try self.mir_instructions.ensureUnusedCapacity(gpa, 1); |
| ... | @@ -3272,40 +3252,32 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live | ... | @@ -3272,40 +3252,32 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live |
| 3272 | self.finishAirBookkeeping(); | 3252 | self.finishAirBookkeeping(); |
| 3273 | } | 3253 | } |
| 3274 | | 3254 | |
| 3275 | fn genArgDbgInfo(self: *Self, inst: Air.Inst.Index, mcv: MCValue, arg_index: u32) !void { | 3255 | fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, mcv: MCValue, arg_index: u32) !void { |
| 3276 | const ty = self.air.instructions.items(.data)[inst].ty; | 3256 | const ty = self.air.instructions.items(.data)[inst].ty; |
| 3277 | const name = self.mod_fn.getParamName(self.bin_file.options.module.?, arg_index); | 3257 | const name = self.mod_fn.getParamName(self.bin_file.options.module.?, arg_index); |
| 3278 | const name_with_null = name.ptr[0 .. name.len + 1]; | 3258 | const atom = self.getDbgInfoAtomPtr(); |
| 3279 | | 3259 | |
| 3280 | switch (mcv) { | 3260 | switch (self.debug_output) { |
| 3281 | .register => |reg| { | 3261 | .dwarf => |dw| switch (mcv) { |
| 3282 | switch (self.debug_output) { | 3262 | .register => |reg| try dw.genArgDbgInfo(name, ty, atom, .{ |
| 3283 | .dwarf => |dw| { | 3263 | .register = reg.dwarfLocOp(), |
| 3284 | const dbg_info = &dw.dbg_info; | 3264 | }), |
| 3285 | try dbg_info.ensureUnusedCapacity(3); | 3265 | else => {}, |
| 3286 | dbg_info.appendAssumeCapacity(@enumToInt(link.File.Dwarf.AbbrevKind.parameter)); | | |
| 3287 | dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc | | |
| 3288 | 1, // ULEB128 dwarf expression length | | |
| 3289 | reg.dwarfLocOp(), | | |
| 3290 | }); | | |
| 3291 | try dbg_info.ensureUnusedCapacity(5 + name_with_null.len); | | |
| 3292 | try self.addDbgInfoTypeReloc(ty); // DW.AT.type, DW.FORM.ref4 | | |
| 3293 | dbg_info.appendSliceAssumeCapacity(name_with_null); // DW.AT.name, DW.FORM.string | | |
| 3294 | }, | | |
| 3295 | else => {}, | | |
| 3296 | } | | |
| 3297 | }, | | |
| 3298 | .stack_offset => |offset| { | | |
| 3299 | _ = offset; | | |
| 3300 | switch (self.debug_output) { | | |
| 3301 | .dwarf => {}, | | |
| 3302 | else => {}, | | |
| 3303 | } | | |
| 3304 | }, | 3266 | }, |
| 3305 | else => {}, | 3267 | else => {}, |
| 3306 | } | 3268 | } |
| 3307 | } | 3269 | } |
| 3308 | | 3270 | |
| | 3271 | fn getDbgInfoAtomPtr(self: Self) *link.File.Dwarf.Atom { |
| | 3272 | const mod = self.bin_file.options.module.?; |
| | 3273 | const fn_owner_decl = mod.declPtr(self.mod_fn.owner_decl); |
| | 3274 | const atom = switch (self.bin_file.tag) { |
| | 3275 | .elf => &fn_owner_decl.link.elf.dbg_info_atom, |
| | 3276 | else => unreachable, |
| | 3277 | }; |
| | 3278 | return atom; |
| | 3279 | } |
| | 3280 | |
| 3309 | // TODO replace this to call to extern memcpy | 3281 | // TODO replace this to call to extern memcpy |
| 3310 | fn genInlineMemcpy( | 3282 | fn genInlineMemcpy( |
| 3311 | self: *Self, | 3283 | self: *Self, |