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 {
45774577 const operand_ty = self.air.typeOf(pl_op.operand);
45784578 const name = self.air.nullTerminatedString(pl_op.payload);
45794579
4580 if (needDbgVarWorkaround(self.dg, operand_ty)) {
4581 return null;
4582 }
4583
45804584 const di_local_var = dib.createAutoVariable(
45814585 self.di_scope.?,
45824586 name.ptr,
......@@ -6147,6 +6151,10 @@ pub const FuncGen = struct {
61476151
61486152 const inst_ty = self.air.typeOfIndex(inst);
61496153 if (self.dg.object.di_builder) |dib| {
6154 if (needDbgVarWorkaround(self.dg, inst_ty)) {
6155 return arg_val;
6156 }
6157
61506158 const src_index = self.getSrcArgIndex(self.arg_index - 1);
61516159 const func = self.dg.decl.getFunction().?;
61526160 const lbrace_line = self.dg.module.declPtr(func.owner_decl).src_line + func.lbrace_line + 1;
......@@ -8248,3 +8256,15 @@ const AnnotatedDITypePtr = enum(usize) {
82488256};
82498257
82508258const 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}