LLVM: fix debug info for local vars

Previously we incorrectly used the pointer type as the debug info type.
This commit is contained in:
Andrew Kelley 2022-03-13 18:18:25 -07:00
parent cb3b1dd6dd
commit eeaaefb925
2 changed files with 11 additions and 2 deletions

View File

@ -4195,7 +4195,15 @@ fn zirDbgVar(
const str_op = sema.code.instructions.items(.data)[inst].str_op;
const operand = sema.resolveInst(str_op.operand);
const operand_ty = sema.typeOf(operand);
if (!(try sema.typeHasRuntimeBits(block, sema.src, operand_ty))) return;
switch (air_tag) {
.dbg_var_ptr => {
if (!(try sema.typeHasRuntimeBits(block, sema.src, operand_ty.childType()))) return;
},
.dbg_var_val => {
if (!(try sema.typeHasRuntimeBits(block, sema.src, operand_ty))) return;
},
else => unreachable,
}
const name = str_op.getStr(sema.code);
// Add the name to the AIR.

View File

@ -3984,13 +3984,14 @@ pub const FuncGen = struct {
const pl_op = self.air.instructions.items(.data)[inst].pl_op;
const operand = try self.resolveInst(pl_op.operand);
const name = self.air.nullTerminatedString(pl_op.payload);
const ptr_ty = self.air.typeOf(pl_op.operand);
const di_local_var = dib.createAutoVariable(
self.di_scope.?,
name.ptr,
self.di_file.?,
self.prev_dbg_line,
try self.dg.lowerDebugType(self.air.typeOf(pl_op.operand)),
try self.dg.lowerDebugType(ptr_ty.childType()),
true, // always preserve
0, // flags
);