zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit eeaaefb925a659f7bab1beea35b7c1b5f567d027 (tree)
parent cb3b1dd6ddee65d1811fb4058b5cc0f2c06d0139
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Sun, 13 Mar 2022 18:18:25 -0700

LLVM: fix debug info for local vars

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

Diffstat:
Msrc/Sema.zig | 10+++++++++-
Msrc/codegen/llvm.zig | 3++-
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/Sema.zig b/src/Sema.zig @@ -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. diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig @@ -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 );