aboutsummaryrefslogtreecommitdiff
path: root/src/arch/sparc64/CodeGen.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-12-02 17:13:52 +0100
committerGitHub <noreply@github.com>2022-12-02 17:13:52 +0100
commit16dc86a49e1e92d036d196be40a4fc073314bcf7 (patch)
tree8842f844da54874ff384398382bf3b2374a071a4 /src/arch/sparc64/CodeGen.zig
parent665eba93c1733f83614c443c19cd9a5f1be910df (diff)
parentbfd36cbf97bfa012e5c399c16578b8756782e1d8 (diff)
downloadzig-16dc86a49e1e92d036d196be40a4fc073314bcf7.tar.gz
zig-16dc86a49e1e92d036d196be40a4fc073314bcf7.zip
Merge pull request #13730 from ziglang/gen-dwarf-simple
dwarf: dedup generation of dwarf info for func args and vars in Dwarf module
Diffstat (limited to 'src/arch/sparc64/CodeGen.zig')
-rw-r--r--src/arch/sparc64/CodeGen.zig57
1 files changed, 11 insertions, 46 deletions
diff --git a/src/arch/sparc64/CodeGen.zig b/src/arch/sparc64/CodeGen.zig
index f22849c652..9f345767de 100644
--- a/src/arch/sparc64/CodeGen.zig
+++ b/src/arch/sparc64/CodeGen.zig
@@ -2460,26 +2460,6 @@ fn airWrapOptional(self: *Self, inst: Air.Inst.Index) !void {
// Common helper functions
-/// Adds a Type to the .debug_info at the current position. The bytes will be populated later,
-/// after codegen for this symbol is done.
-fn addDbgInfoTypeReloc(self: *Self, ty: Type) !void {
- switch (self.debug_output) {
- .dwarf => |dw| {
- assert(ty.hasRuntimeBits());
- const dbg_info = &dw.dbg_info;
- const index = dbg_info.items.len;
- try dbg_info.resize(index + 4); // DW.AT.type, DW.FORM.ref4
- const mod = self.bin_file.options.module.?;
- const atom = switch (self.bin_file.tag) {
- .elf => &mod.declPtr(self.mod_fn.owner_decl).link.elf.dbg_info_atom,
- else => unreachable,
- };
- try dw.addTypeRelocGlobal(atom, ty, @intCast(u32, index));
- },
- else => {},
- }
-}
-
fn addInst(self: *Self, inst: Mir.Inst) error{OutOfMemory}!Mir.Inst.Index {
const gpa = self.gpa;
try self.mir_instructions.ensureUnusedCapacity(gpa, 1);
@@ -3272,35 +3252,20 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live
self.finishAirBookkeeping();
}
-fn genArgDbgInfo(self: *Self, inst: Air.Inst.Index, mcv: MCValue, arg_index: u32) !void {
+fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, mcv: MCValue, arg_index: u32) !void {
const ty = self.air.instructions.items(.data)[inst].ty;
const name = self.mod_fn.getParamName(self.bin_file.options.module.?, arg_index);
- const name_with_null = name.ptr[0 .. name.len + 1];
- switch (mcv) {
- .register => |reg| {
- switch (self.debug_output) {
- .dwarf => |dw| {
- const dbg_info = &dw.dbg_info;
- try dbg_info.ensureUnusedCapacity(3);
- dbg_info.appendAssumeCapacity(@enumToInt(link.File.Dwarf.AbbrevKind.parameter));
- dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc
- 1, // ULEB128 dwarf expression length
- reg.dwarfLocOp(),
- });
- try dbg_info.ensureUnusedCapacity(5 + name_with_null.len);
- try self.addDbgInfoTypeReloc(ty); // DW.AT.type, DW.FORM.ref4
- dbg_info.appendSliceAssumeCapacity(name_with_null); // DW.AT.name, DW.FORM.string
- },
- else => {},
- }
- },
- .stack_offset => |offset| {
- _ = offset;
- switch (self.debug_output) {
- .dwarf => {},
- else => {},
- }
+ switch (self.debug_output) {
+ .dwarf => |dw| switch (mcv) {
+ .register => |reg| try dw.genArgDbgInfo(
+ name,
+ ty,
+ self.bin_file.tag,
+ self.mod_fn.owner_decl,
+ .{ .register = reg.dwarfLocOp() },
+ ),
+ else => {},
},
else => {},
}