LLVM: insert workaround for aarch64-windows f16 CodeView crash

This commit is contained in:
Andrew Kelley 2022-05-02 21:16:18 -07:00
parent 76b7f56725
commit defda6202a

View File

@ -4577,6 +4577,10 @@ pub const FuncGen = struct {
const operand_ty = self.air.typeOf(pl_op.operand);
const name = self.air.nullTerminatedString(pl_op.payload);
if (needDbgVarWorkaround(self.dg, operand_ty)) {
return null;
}
const di_local_var = dib.createAutoVariable(
self.di_scope.?,
name.ptr,
@ -6147,6 +6151,10 @@ pub const FuncGen = struct {
const inst_ty = self.air.typeOfIndex(inst);
if (self.dg.object.di_builder) |dib| {
if (needDbgVarWorkaround(self.dg, inst_ty)) {
return arg_val;
}
const src_index = self.getSrcArgIndex(self.arg_index - 1);
const func = self.dg.decl.getFunction().?;
const lbrace_line = self.dg.module.declPtr(func.owner_decl).src_line + func.lbrace_line + 1;
@ -8248,3 +8256,15 @@ const AnnotatedDITypePtr = enum(usize) {
};
const lt_errors_fn_name = "__zig_lt_errors_len";
/// Without this workaround, LLVM crashes with "unknown codeview register H1"
/// TODO use llvm-reduce and file upstream LLVM bug for this.
fn needDbgVarWorkaround(dg: *DeclGen, ty: Type) bool {
if (ty.tag() == .f16) {
const target = dg.module.getTarget();
if (target.os.tag == .windows and target.cpu.arch == .aarch64) {
return true;
}
}
return false;
}