diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 6453ea04a323..6c22d2fa7215 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -6709,8 +6709,6 @@ pub const FuncGen = struct { const operand_ty = self.typeOf(pl_op.operand); const name = self.air.nullTerminatedString(pl_op.payload); - if (needDbgVarWorkaround(o)) return .none; - const debug_local_var = try o.builder.debugLocalVar( try o.builder.metadataString(name), self.file, @@ -6734,7 +6732,10 @@ pub const FuncGen = struct { }, "", ); - } else if (owner_mod.optimize_mode == .Debug) { + } else if (owner_mod.optimize_mode == .Debug and !self.is_naked) { + // We avoid taking this path for naked functions because there's no guarantee that such + // functions even have a valid stack pointer, making the `alloca` + `store` unsafe. + const alignment = operand_ty.abiAlignment(pt).toLlvm(); const alloca = try self.buildAlloca(operand.typeOfWip(&self.wip), alignment); _ = try self.wip.store(.normal, operand, alloca, alignment); @@ -8815,7 +8816,6 @@ pub const FuncGen = struct { if (self.is_naked) return arg_val; const inst_ty = self.typeOfIndex(inst); - if (needDbgVarWorkaround(o)) return arg_val; const name = self.air.instructions.items(.data)[@intFromEnum(inst)].arg.name; if (name == .none) return arg_val; @@ -11804,16 +11804,6 @@ const optional_layout_version = 3; const lt_errors_fn_name = "__zig_lt_errors_len"; -/// Without this workaround, LLVM crashes with "unknown codeview register H1" -/// https://github.com/llvm/llvm-project/issues/56484 -fn needDbgVarWorkaround(o: *Object) bool { - const target = o.pt.zcu.getTarget(); - if (target.os.tag == .windows and target.cpu.arch == .aarch64) { - return true; - } - return false; -} - fn compilerRtIntBits(bits: u16) u16 { inline for (.{ 32, 64, 128 }) |b| { if (bits <= b) {