authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-02 21:16:18-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-02 22:14:17-07:00
logdefda6202a5c9fd50f465b3a6a9728ba5d636a38
treeb01179a2f3eaa544aaab15772e8d10957a7694cf
parent76b7f5672511be454a14b909446ed6464244c1e9

LLVM: insert workaround for aarch64-windows f16 CodeView crash


1 files changed, 20 insertions(+), 0 deletions(-)

src/codegen/llvm.zig+20
...@@ -4577,6 +4577,10 @@ pub const FuncGen = struct {...@@ -4577,6 +4577,10 @@ pub const FuncGen = struct {
4577 const operand_ty = self.air.typeOf(pl_op.operand);4577 const operand_ty = self.air.typeOf(pl_op.operand);
4578 const name = self.air.nullTerminatedString(pl_op.payload);4578 const name = self.air.nullTerminatedString(pl_op.payload);
45794579
4580 if (needDbgVarWorkaround(self.dg, operand_ty)) {
4581 return null;
4582 }
4583
4580 const di_local_var = dib.createAutoVariable(4584 const di_local_var = dib.createAutoVariable(
4581 self.di_scope.?,4585 self.di_scope.?,
4582 name.ptr,4586 name.ptr,
...@@ -6147,6 +6151,10 @@ pub const FuncGen = struct {...@@ -6147,6 +6151,10 @@ pub const FuncGen = struct {
61476151
6148 const inst_ty = self.air.typeOfIndex(inst);6152 const inst_ty = self.air.typeOfIndex(inst);
6149 if (self.dg.object.di_builder) |dib| {6153 if (self.dg.object.di_builder) |dib| {
6154 if (needDbgVarWorkaround(self.dg, inst_ty)) {
6155 return arg_val;
6156 }
6157
6150 const src_index = self.getSrcArgIndex(self.arg_index - 1);6158 const src_index = self.getSrcArgIndex(self.arg_index - 1);
6151 const func = self.dg.decl.getFunction().?;6159 const func = self.dg.decl.getFunction().?;
6152 const lbrace_line = self.dg.module.declPtr(func.owner_decl).src_line + func.lbrace_line + 1;6160 const lbrace_line = self.dg.module.declPtr(func.owner_decl).src_line + func.lbrace_line + 1;
...@@ -8248,3 +8256,15 @@ const AnnotatedDITypePtr = enum(usize) {...@@ -8248,3 +8256,15 @@ const AnnotatedDITypePtr = enum(usize) {
8248};8256};
82498257
8250const lt_errors_fn_name = "__zig_lt_errors_len";8258const lt_errors_fn_name = "__zig_lt_errors_len";
8259
8260/// Without this workaround, LLVM crashes with "unknown codeview register H1"
8261/// TODO use llvm-reduce and file upstream LLVM bug for this.
8262fn needDbgVarWorkaround(dg: *DeclGen, ty: Type) bool {
8263 if (ty.tag() == .f16) {
8264 const target = dg.module.getTarget();
8265 if (target.os.tag == .windows and target.cpu.arch == .aarch64) {
8266 return true;
8267 }
8268 }
8269 return false;
8270}