authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-13 18:18:25-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-14 00:11:46-07:00
logeeaaefb925a659f7bab1beea35b7c1b5f567d027
treed5514c85d14fa9cb261f29654385932dc4daa59f
parentcb3b1dd6ddee65d1811fb4058b5cc0f2c06d0139

LLVM: fix debug info for local vars

Previously we incorrectly used the pointer type as the debug info type.

2 files changed, 11 insertions(+), 2 deletions(-)

src/Sema.zig+9-1
......@@ -4195,7 +4195,15 @@ fn zirDbgVar(
41954195 const str_op = sema.code.instructions.items(.data)[inst].str_op;
41964196 const operand = sema.resolveInst(str_op.operand);
41974197 const operand_ty = sema.typeOf(operand);
4198 if (!(try sema.typeHasRuntimeBits(block, sema.src, operand_ty))) return;
4198 switch (air_tag) {
4199 .dbg_var_ptr => {
4200 if (!(try sema.typeHasRuntimeBits(block, sema.src, operand_ty.childType()))) return;
4201 },
4202 .dbg_var_val => {
4203 if (!(try sema.typeHasRuntimeBits(block, sema.src, operand_ty))) return;
4204 },
4205 else => unreachable,
4206 }
41994207 const name = str_op.getStr(sema.code);
42004208
42014209 // Add the name to the AIR.
src/codegen/llvm.zig+2-1
......@@ -3984,13 +3984,14 @@ pub const FuncGen = struct {
39843984 const pl_op = self.air.instructions.items(.data)[inst].pl_op;
39853985 const operand = try self.resolveInst(pl_op.operand);
39863986 const name = self.air.nullTerminatedString(pl_op.payload);
3987 const ptr_ty = self.air.typeOf(pl_op.operand);
39873988
39883989 const di_local_var = dib.createAutoVariable(
39893990 self.di_scope.?,
39903991 name.ptr,
39913992 self.di_file.?,
39923993 self.prev_dbg_line,
3993 try self.dg.lowerDebugType(self.air.typeOf(pl_op.operand)),
3994 try self.dg.lowerDebugType(ptr_ty.childType()),
39943995 true, // always preserve
39953996 0, // flags
39963997 );