authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-11 16:44:09-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-12 18:38:11-07:00
log0d164f9a25f05a2917f4e1d4eb21c85b3279b47b
treedb2bec37d9668490c09c892e9cef2d9901d82440
parentd789c687172166fe599d6b4cec2993f25f75989e

LLVM: broaden aarch64-windows f16 debug variable workaround

LLVM does not properly handle debug info for f16 on the aarch64-windows target, causing "fatal error: unknown codeview register H1". The previous workaround checked only for f16 but was still vulnerable if a type was a byval struct or tuple which had an f16 field in it. Now I have filed an upstream issue (see https://github.com/llvm/llvm-project/issues/56484) and broadened the workaround to always skip debug values for this target.

1 files changed, 7 insertions(+), 9 deletions(-)

src/codegen/llvm.zig+7-9
......@@ -5244,7 +5244,7 @@ pub const FuncGen = struct {
52445244 const operand_ty = self.air.typeOf(pl_op.operand);
52455245 const name = self.air.nullTerminatedString(pl_op.payload);
52465246
5247 if (needDbgVarWorkaround(self.dg, operand_ty)) {
5247 if (needDbgVarWorkaround(self.dg)) {
52485248 return null;
52495249 }
52505250
......@@ -6988,7 +6988,7 @@ pub const FuncGen = struct {
69886988
69896989 const inst_ty = self.air.typeOfIndex(inst);
69906990 if (self.dg.object.di_builder) |dib| {
6991 if (needDbgVarWorkaround(self.dg, inst_ty)) {
6991 if (needDbgVarWorkaround(self.dg)) {
69926992 return arg_val;
69936993 }
69946994
......@@ -9255,13 +9255,11 @@ const AnnotatedDITypePtr = enum(usize) {
92559255const lt_errors_fn_name = "__zig_lt_errors_len";
92569256
92579257/// Without this workaround, LLVM crashes with "unknown codeview register H1"
9258/// TODO use llvm-reduce and file upstream LLVM bug for this.
9259fn needDbgVarWorkaround(dg: *DeclGen, ty: Type) bool {
9260 if (ty.tag() == .f16) {
9261 const target = dg.module.getTarget();
9262 if (target.os.tag == .windows and target.cpu.arch == .aarch64) {
9263 return true;
9264 }
9258/// https://github.com/llvm/llvm-project/issues/56484
9259fn needDbgVarWorkaround(dg: *DeclGen) bool {
9260 const target = dg.module.getTarget();
9261 if (target.os.tag == .windows and target.cpu.arch == .aarch64) {
9262 return true;
92659263 }
92669264 return false;
92679265}