Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-cl|ICE] fatal error: error in backend: unknown codeview register R8BH #73538

Closed
Neumann-A opened this issue Nov 27, 2023 · 11 comments
Closed
Assignees
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] duplicate Resolved as duplicate llvm:codegen

Comments

@Neumann-A
Copy link

Neumann-A commented Nov 27, 2023

fatal error: error in backend: unknown codeview register R8BH
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: C:\\PROGRA~1\\LLVM\\bin\\clang-cl.exe -cc1 -triple x86_64-pc-windows-msvc19.38.33130 -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name data.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -target-feature +crc32 -target-feature +sse4.2 -target-feature +aes -target-feature +pclmul -target-feature +sse -target-feature +sse2 -target-feature +sse3 -mllvm -x86-asm-syntax=intel -tune-cpu generic -D_MT -D_DLL --dependent-lib=msvcrt --dependent-lib=oldnames --show-includes -sys-header-deps -stack-protector 2 -fcxx-exceptions -fexceptions -fasync-exceptions -fms-volatile -fdiagnostics-format msvc -gno-column-info -gcodeview -debug-info-kind=constructor -ffunction-sections -fcoverage-compilation-dir=E:\\all\\vcpkg\\buildtrees\\opencv4\\x64-win-llvm-release-rel -D CVAPI_EXPORTS -D _USE_MATH_DEFINES -D _VARIADIC_MAX=10 -D __OPENCV_BUILD=1 -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D WIN32 -D _WIN64 -D _WIN32_WINNT=0x0A00 -D WINVER=0x0A00 -D _CRT_SECURE_NO_DEPRECATE -D _CRT_SECURE_NO_WARNINGS -D _CRT_NONSTDC_NO_DEPRECATE -D _ATL_SECURE_NO_DEPRECATE -D _SCL_SECURE_NO_WARNINGS -D _CRT_INTERNAL_NONSTDC_NAMES -D _CRT_DECLARE_NONSTDC_NAMES -D _FORCENAMELESSUNION -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE -D _SCL_SECURE_NO_WARNINGS -D NDEBUG -D NDEBUG -O2 -Wno-error -W -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -Wno-long-long -fdeprecated-macro -fdebug-compilation-dir=E:\\all\\vcpkg\\buildtrees\\opencv4\\x64-win-llvm-release-rel -ferror-limit 19 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.38.33130 -std=c++14 -fdelayed-template-parsing -vectorize-loops -vectorize-slp -faddrsig -object-file-name=E:\\all\\vcpkg\\buildtrees\\opencv4\\x64-win-llvm-release-rel\\modules\\ml\\CMakeFiles\\opencv_ml.dir\\src\\data.cpp.obj -x c++ data-ef81aa.cpp
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'data-ef81aa.cpp'.
4.      Running pass 'X86 Assembly Printer' on function '@"??$construct@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@std@@AEBUpiecewise_construct_t@2@V?$tuple@$$QEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$tuple@$$V@2@@?$_Default_allocator_traits@V?$allocator@U?$_Tree_node@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@std@@PEAX@std@@@std@@@std@@SAXAEAV?$allocator@U?$_Tree_node@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@std@@PEAX@std@@@1@QEAU?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@1@AEBUpiecewise_construct_t@1@$$QEAV?$tuple@$$QEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@1@$$QEAV?$tuple@$$V@1@@Z"'

data-ef81aa.cpp.txt
data-ef81aa.sh.txt

seems to be related to #69428

@EugeneZelenko EugeneZelenko added backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Nov 27, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 27, 2023

@llvm/issue-subscribers-backend-x86

Author: Alexander Neumann (Neumann-A)

``` fatal error: error in backend: unknown codeview register R8BH 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: C:\\PROGRA~1\\LLVM\\bin\\clang-cl.exe -cc1 -triple x86_64-pc-windows-msvc19.38.33130 -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name data.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -target-feature +crc32 -target-feature +sse4.2 -target-feature +aes -target-feature +pclmul -target-feature +sse -target-feature +sse2 -target-feature +sse3 -mllvm -x86-asm-syntax=intel -tune-cpu generic -D_MT -D_DLL --dependent-lib=msvcrt --dependent-lib=oldnames --show-includes -sys-header-deps -stack-protector 2 -fcxx-exceptions -fexceptions -fasync-exceptions -fms-volatile -fdiagnostics-format msvc -gno-column-info -gcodeview -debug-info-kind=constructor -ffunction-sections -fcoverage-compilation-dir=E:\\all\\vcpkg\\buildtrees\\opencv4\\x64-win-llvm-release-rel -D CVAPI_EXPORTS -D _USE_MATH_DEFINES -D _VARIADIC_MAX=10 -D __OPENCV_BUILD=1 -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D WIN32 -D _WIN64 -D _WIN32_WINNT=0x0A00 -D WINVER=0x0A00 -D _CRT_SECURE_NO_DEPRECATE -D _CRT_SECURE_NO_WARNINGS -D _CRT_NONSTDC_NO_DEPRECATE -D _ATL_SECURE_NO_DEPRECATE -D _SCL_SECURE_NO_WARNINGS -D _CRT_INTERNAL_NONSTDC_NAMES -D _CRT_DECLARE_NONSTDC_NAMES -D _FORCENAMELESSUNION -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE -D _SCL_SECURE_NO_WARNINGS -D NDEBUG -D NDEBUG -O2 -Wno-error -W -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -Wno-long-long -fdeprecated-macro -fdebug-compilation-dir=E:\\all\\vcpkg\\buildtrees\\opencv4\\x64-win-llvm-release-rel -ferror-limit 19 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.38.33130 -std=c++14 -fdelayed-template-parsing -vectorize-loops -vectorize-slp -faddrsig -object-file-name=E:\\all\\vcpkg\\buildtrees\\opencv4\\x64-win-llvm-release-rel\\modules\\ml\\CMakeFiles\\opencv_ml.dir\\src\\data.cpp.obj -x c++ data-ef81aa.cpp 1. <eof> parser at end of file 2. Code generation 3. Running pass 'Function Pass Manager' on module 'data-ef81aa.cpp'. 4. Running pass 'X86 Assembly Printer' on function '@"??$construct@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@std@@AEBUpiecewise_construct_t@2@V?$tuple@$$QEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$tuple@$$V@2@@?$_Default_allocator_traits@V?$allocator@U?$_Tree_node@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@std@@PEAX@std@@@std@@@std@@SAXAEAV?$allocator@U?$_Tree_node@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@std@@PEAX@std@@@1@QEAU?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@1@AEBUpiecewise_construct_t@1@$$QEAV?$tuple@$$QEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@1@$$QEAV?$tuple@$$V@1@@Z"' ``` [data-ef81aa.cpp.txt](https://github.com/llvm/llvm-project/files/13477776/data-ef81aa.cpp.txt) [data-ef81aa.sh.txt](https://github.com/llvm/llvm-project/files/13477790/data-ef81aa.sh.txt)

@KanRobert KanRobert self-assigned this Nov 28, 2023
@KanRobert
Copy link
Contributor

KanRobert commented Nov 28, 2023

R8BH should not be allocated at all. It sounds a bug of codegen instead of codeview

@KanRobert
Copy link
Contributor

I got a different error when using the provided reproducer

A single unwind edge may only enter one EH pad
  invoke void @llvm.seh.scope.end()
          to label %48 unwind label %46, !dbg !16431
clang: /export/users/skan/llvm-project/llvm/lib/CodeGen/WinEHPrepare.cpp:1197: bool {anonymous}::WinEHPrepare::prepareExplicitEH(llvm::Function&): Assertion `!verifyFunction(F, &dbgs())' failed.
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:

Could you dump the IR? (-S -emit-llvm) @Neumann-A

@Neumann-A
Copy link
Author

You are seeing #73536 which is the crash you get with current master. The crash here is with last release. Do you still need the IR in this case? I am currently trying to bisect for #73536 but it is kind of difficult since there seem to be 3 different ICEs which might all be the same but give slightly different errors.

@KanRobert
Copy link
Contributor

Do you need the fix to be in last release? Or in trunk is sufficient?

@Neumann-A
Copy link
Author

Do you need the fix to be in last release? Or in trunk is sufficient?

I don't care about that but somebody else might. LLVM 17 and trunk are not currently able to compile opencv using clang-cl due to this.

@KanRobert
Copy link
Contributor

KanRobert commented Nov 28, 2023

LLVM 17 and trunk are not currently able to compile opencv using clang-cl due to this.

I didn't get your idea. I think the blocking is due to #73536 instead of this one. We need a reproducer for this issue if you would like the error "unknown codeview register R8BH" to be fixed.

@Neumann-A
Copy link
Author

I think #73536 is related to this one. bisect is done and the offending commit is 0efe111:

$ git bisect bad
0efe111365ae176671e01252d24028047d807a84 is the first bad commit
commit 0efe111365ae176671e01252d24028047d807a84
Author: Phoebe Wang <phoebe.wang@intel.com>
Date:   Wed Mar 29 08:20:14 2023 +0800

    Reland "[Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 2"

    This reverts commit db6a979ae82410e42430e47afa488936ba8e3025.

    Reland D102817 without any change. The previous revert was a mistake.

    Differential Revision: https://reviews.llvm.org/D102817

 llvm/include/llvm/CodeGen/SelectionDAGISel.h       |   3 +
 llvm/include/llvm/CodeGen/WinEHFuncInfo.h          |   9 +
 llvm/include/llvm/IR/BasicBlock.h                  |   9 +
 llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp         |  18 +-
 llvm/lib/CodeGen/AsmPrinter/WinException.cpp       |   6 +-
 llvm/lib/CodeGen/BranchFolding.cpp                 |   2 +-
 .../CodeGen/SelectionDAG/SelectionDAGBuilder.cpp   |   5 +
 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp |  42 ++
 llvm/lib/CodeGen/WinEHPrepare.cpp                  | 140 ++++++
 llvm/lib/IR/BasicBlock.cpp                         |   9 +
 llvm/lib/IR/EHPersonalities.cpp                    |   7 +-
 .../X86/windows-seh-EHa-CppCatchDotDotDot.ll       | 290 +++++++++++
 .../CodeGen/X86/windows-seh-EHa-CppCondiTemps.ll   | 543 +++++++++++++++++++++
 .../test/CodeGen/X86/windows-seh-EHa-CppDtors01.ll | 255 ++++++++++
 .../CodeGen/X86/windows-seh-EHa-TryInFinally.ll    | 224 +++++++++
 15 files changed, 1558 insertions(+), 4 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/windows-seh-EHa-CppCatchDotDotDot.ll
 create mode 100644 llvm/test/CodeGen/X86/windows-seh-EHa-CppCondiTemps.ll
 create mode 100644 llvm/test/CodeGen/X86/windows-seh-EHa-CppDtors01.ll
 create mode 100644 llvm/test/CodeGen/X86/windows-seh-EHa-TryInFinally.ll

given the PR details I think it is very likely that solving #73536 also solves this issue.

cc @phoebewang?

@Neumann-A
Copy link
Author

Starting with e3cf80c the ICE is transformed into a hang which is probably the observation from #69428. I'll bisect further to see when the hang becomes #73536

@Neumann-A
Copy link
Author

I simply revert 0efe111 and opencv builds fine again. No ICEs no hangs.

@KanRobert
Copy link
Contributor

duplicated with #73536

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] duplicate Resolved as duplicate llvm:codegen
Projects
None yet
Development

No branches or pull requests

4 participants