Skip to content

"fatal error: unknown codeview register H1" when using @llvm.dbg.value on a half float parameter on aarch64-windows #56484

Closed
@andrewrk

Description

@andrewrk

Repro

Tested with 14.0.6.

$ ~/local/llvm14-release/bin/clang-14 reduced.ll -target aarch64-windows-gnu
fatal error: error in backend: unknown codeview register H1
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /home/andy/local/llvm14-release/bin/clang-14 -c test2.ll -target aarch64-windows-gnu
1.	Code generation
2.	Running pass 'Function Pass Manager' on module 'test2.ll'.
3.	Running pass 'AArch64 Assembly Printer' on function '@test2.isNan__anon_222'
 #0 0x0000000002f2bd20 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000000002f29c5c llvm::sys::CleanupOnSignal(unsigned long) (/home/andy/local/llvm14-release/bin/clang-14+0x2f29c5c)
 #2 0x0000000002e67b84 llvm::CrashRecoveryContext::HandleExit(int) (/home/andy/local/llvm14-release/bin/clang-14+0x2e67b84)
 #3 0x0000000002f2226e llvm::sys::Process::Exit(int, bool) (/home/andy/local/llvm14-release/bin/clang-14+0x2f2226e)
 #4 0x0000000000a5b123 (/home/andy/local/llvm14-release/bin/clang-14+0xa5b123)
 #5 0x0000000002e6e5c2 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/andy/local/llvm14-release/bin/clang-14+0x2e6e5c2)
 #6 0x0000000002af595c llvm::MCRegisterInfo::getCodeViewRegNum(llvm::MCRegister) const (/home/andy/local/llvm14-release/bin/clang-14+0x2af595c)
 #7 0x0000000003c7415a llvm::CodeViewDebug::calculateRanges(llvm::CodeViewDebug::LocalVariable&, llvm::SmallVector<llvm::DbgValueHistoryMap::Entry, 4u> const&) (/home/andy/local/llvm14-release/bin/clang-14+0x3c7415a)
 #8 0x0000000003c89fbc llvm::CodeViewDebug::collectVariableInfo(llvm::DISubprogram const*) (/home/andy/local/llvm14-release/bin/clang-14+0x3c89fbc)
 #9 0x0000000003c8a111 llvm::CodeViewDebug::endFunctionImpl(llvm::MachineFunction const*) (/home/andy/local/llvm14-release/bin/clang-14+0x3c8a111)
#10 0x0000000003c23677 llvm::DebugHandlerBase::endFunction(llvm::MachineFunction const*) (/home/andy/local/llvm14-release/bin/clang-14+0x3c23677)
#11 0x0000000003c1e591 llvm::AsmPrinter::emitFunctionBody() (/home/andy/local/llvm14-release/bin/clang-14+0x3c1e591)
#12 0x0000000000a6a6f8 (anonymous namespace)::AArch64AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) AArch64AsmPrinter.cpp:0:0
#13 0x00000000021cdb14 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/andy/local/llvm14-release/bin/clang-14+0x21cdb14)
#14 0x0000000002638a00 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/andy/local/llvm14-release/bin/clang-14+0x2638a00)
#15 0x0000000002638b6c llvm::FPPassManager::runOnModule(llvm::Module&) (/home/andy/local/llvm14-release/bin/clang-14+0x2638b6c)
#16 0x000000000263a4f1 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/andy/local/llvm14-release/bin/clang-14+0x263a4f1)
#17 0x000000000325f2e1 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/home/andy/local/llvm14-release/bin/clang-14+0x325f2e1)
#18 0x0000000003f6d0f8 clang::CodeGenAction::ExecuteAction() (/home/andy/local/llvm14-release/bin/clang-14+0x3f6d0f8)
#19 0x000000000391b219 clang::FrontendAction::Execute() (/home/andy/local/llvm14-release/bin/clang-14+0x391b219)
#20 0x00000000038aba6b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/andy/local/llvm14-release/bin/clang-14+0x38aba6b)
#21 0x00000000039cb820 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/andy/local/llvm14-release/bin/clang-14+0x39cb820)
#22 0x0000000000a5c51c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/andy/local/llvm14-release/bin/clang-14+0xa5c51c)
#23 0x0000000000a59479 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#24 0x00000000037325a5 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#25 0x0000000002e67a13 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/andy/local/llvm14-release/bin/clang-14+0x2e67a13)
#26 0x0000000003732904 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (.part.0) Job.cpp:0:0
#27 0x0000000003705556 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/home/andy/local/llvm14-release/bin/clang-14+0x3705556)
#28 0x0000000003705f09 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/home/andy/local/llvm14-release/bin/clang-14+0x3705f09)
#29 0x0000000003715409 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/home/andy/local/llvm14-release/bin/clang-14+0x3715409)

reduced.ll

define internal fastcc i1 @test2.isNan__anon_222(half %0) !dbg !33 {
Entry:
  call void @llvm.dbg.value(metadata half %0, metadata !40, metadata !DIExpression()), !dbg !42
  %1 = fcmp une half 0xH0000, %0, !dbg !43
  ret i1 %1
}

; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
declare void @llvm.dbg.value(metadata, metadata, metadata) #0

attributes #0 = { nofree nosync nounwind readnone speculatable willreturn }

!llvm.module.flags = !{!0, !1, !2}
!llvm.dbg.cu = !{!3}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 2, !"CodeView", i32 1}
!2 = !{i32 7, !"PIC Level", i32 2}
!3 = distinct !DICompileUnit(language: DW_LANG_C99, file: !4, producer: "zig 0.10.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, globals: !27)
!4 = !DIFile(filename: "test2", directory: ".")
!5 = !{!6, !21}
!6 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "builtin.CompilerBackend", scope: !7, file: !7, line: 1222, baseType: !8, size: 64, align: 64, elements: !9)
!7 = !DIFile(filename: "builtin.zig", directory: "/home/andy/dev/zig/lib/std")
!8 = !DIBasicType(name: "u64", size: 64, encoding: DW_ATE_unsigned)
!9 = !{!10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20}
!10 = !DIEnumerator(name: "other", value: 0)
!11 = !DIEnumerator(name: "stage1", value: 1)
!12 = !DIEnumerator(name: "stage2_llvm", value: 2)
!13 = !DIEnumerator(name: "stage2_c", value: 3)
!14 = !DIEnumerator(name: "stage2_wasm", value: 4)
!15 = !DIEnumerator(name: "stage2_arm", value: 5)
!16 = !DIEnumerator(name: "stage2_x86_64", value: 6)
!17 = !DIEnumerator(name: "stage2_aarch64", value: 7)
!18 = !DIEnumerator(name: "stage2_x86", value: 8)
!19 = !DIEnumerator(name: "stage2_riscv64", value: 9)
!20 = !DIEnumerator(name: "stage2_sparc64", value: 10)
!21 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "builtin.OutputMode", scope: !7, file: !7, line: 533, baseType: !22, size: 8, align: 8, elements: !23)
!22 = !DIBasicType(name: "u2", size: 2, encoding: DW_ATE_unsigned)
!23 = !{!24, !25, !26}
!24 = !DIEnumerator(name: "Exe", value: 0)
!25 = !DIEnumerator(name: "Lib", value: 1)
!26 = !DIEnumerator(name: "Obj", value: 2)
!27 = !{!28, !31}
!28 = !DIGlobalVariableExpression(var: !29, expr: !DIExpression())
!29 = distinct !DIGlobalVariable(name: "zig_backend", linkageName: "builtin.zig_backend", scope: !30, file: !30, line: 5, type: !6, isLocal: true, isDefinition: true)
!30 = !DIFile(filename: "builtin.zig", directory: "zig-cache/o/dad7b6fae1ca78a1c1cb52547270f805")
!31 = !DIGlobalVariableExpression(var: !32, expr: !DIExpression())
!32 = distinct !DIGlobalVariable(name: "output_mode", linkageName: "builtin.output_mode", scope: !30, file: !30, line: 9, type: !21, isLocal: true, isDefinition: true)
!33 = distinct !DISubprogram(name: "isNan__anon_222", linkageName: "test2.isNan__anon_222", scope: !34, file: !34, line: 32, type: !35, scopeLine: 32, flags: DIFlagStaticMember, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !3, retainedNodes: !39)
!34 = !DIFile(filename: "test2.zig", directory: ".")
!35 = !DISubroutineType(types: !36)
!36 = !{!37, !38}
!37 = !DIBasicType(name: "bool", size: 1, encoding: DW_ATE_boolean)
!38 = !DIBasicType(name: "f16", size: 16, encoding: DW_ATE_float)
!39 = !{!40}
!40 = !DILocalVariable(name: "x", arg: 1, scope: !41, file: !34, line: 32, type: !38)
!41 = distinct !DILexicalBlock(scope: !33, file: !34, line: 32, column: 1)
!42 = !DILocation(line: 32, column: 31, scope: !41)
!43 = !DILocation(line: 33, column: 5, scope: !44)
!44 = distinct !DILexicalBlock(scope: !41, file: !34)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions