Commit 56119699bf

Jacob Young <jacobly0@users.noreply.github.com>
2025-06-09 08:35:45
x86_64: fix `dbg_var_ptr` types in debug info
1 parent a3abaae
Changed files (2)
src
src/arch/x86_64/bits.zig
@@ -686,8 +686,6 @@ test "Register id - different classes" {
     try expect(Register.xmm0.id() == Register.ymm0.id());
     try expect(Register.xmm0.id() != Register.mm0.id());
     try expect(Register.mm0.id() != Register.st0.id());
-
-    try expect(Register.es.id() == 0b110000);
 }
 
 test "Register enc - different classes" {
src/arch/x86_64/CodeGen.zig
@@ -85046,13 +85046,15 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
                     .data = .{ .ip_index = old_inline_func },
                 });
             },
-            .dbg_var_ptr,
-            .dbg_var_val,
-            .dbg_arg_inline,
-            => |air_tag| if (use_old) try cg.airDbgVar(inst) else if (!cg.mod.strip) {
+            .dbg_var_ptr, .dbg_var_val, .dbg_arg_inline => |air_tag| if (use_old) try cg.airDbgVar(inst) else if (!cg.mod.strip) {
                 const pl_op = air_datas[@intFromEnum(inst)].pl_op;
                 const air_name: Air.NullTerminatedString = @enumFromInt(pl_op.payload);
-                const ty = cg.typeOf(pl_op.operand);
+                const op_ty = cg.typeOf(pl_op.operand);
+                const local_ty = switch (air_tag) {
+                    else => unreachable,
+                    .dbg_var_ptr => op_ty.childType(zcu),
+                    .dbg_var_val, .dbg_arg_inline => op_ty,
+                };
                 var ops = try cg.tempsFromOperands(inst, .{pl_op.operand});
                 var mcv = ops[0].tracking(cg).short;
                 switch (mcv) {
@@ -85076,10 +85078,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
                         },
                         else => try cg.addString(air_name.toSlice(cg.air)),
                     },
-                    .type = ty.toIntern(),
+                    .type = local_ty.toIntern(),
                 });
 
-                try cg.genLocalDebugInfo(air_tag, ty, ops[0].tracking(cg).short);
+                try cg.genLocalDebugInfo(air_tag, local_ty, ops[0].tracking(cg).short);
                 try ops[0].die(cg);
             },
             .is_null => if (use_old) try cg.airIsNull(inst) else {
@@ -174364,7 +174366,12 @@ fn airDbgVar(cg: *CodeGen, inst: Air.Inst.Index) !void {
     const air_tag = cg.air.instructions.items(.tag)[@intFromEnum(inst)];
     const pl_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
     const air_name: Air.NullTerminatedString = @enumFromInt(pl_op.payload);
-    const ty = cg.typeOf(pl_op.operand);
+    const op_ty = cg.typeOf(pl_op.operand);
+    const local_ty = switch (air_tag) {
+        else => unreachable,
+        .dbg_var_ptr => op_ty.childType(cg.pt.zcu),
+        .dbg_var_val, .dbg_arg_inline => op_ty,
+    };
 
     try cg.mir_locals.append(cg.gpa, .{
         .name = switch (air_name) {
@@ -174374,10 +174381,10 @@ fn airDbgVar(cg: *CodeGen, inst: Air.Inst.Index) !void {
             },
             else => try cg.addString(air_name.toSlice(cg.air)),
         },
-        .type = ty.toIntern(),
+        .type = local_ty.toIntern(),
     });
 
-    try cg.genLocalDebugInfo(air_tag, ty, try cg.resolveInst(pl_op.operand));
+    try cg.genLocalDebugInfo(air_tag, local_ty, try cg.resolveInst(pl_op.operand));
     return cg.finishAir(inst, .unreach, .{ pl_op.operand, .none, .none });
 }