<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64278>64278</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
"fatal error: unknown codeview register D1_D2" when compiling with `-O1 -g -gcodeview` on armv7-windows
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kleisauke
</td>
</tr>
</table>
<pre>
### Repro
Tested with LLVM 17.0.0-rc1.
```console
$ docker run --rm -v $(pwd):/repro -w /repro -it mstorsjo/llvm-mingw:latest armv7-w64-mingw32-clang -O1 -g -gcodeview -c reduced.c
fatal error: error in backend: unknown codeview register D1_D2
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: /opt/llvm-mingw/bin/clang --start-no-unused-arguments -target armv7-w64-mingw32 -rtlib=compiler-rt -unwindlib=libunwind -stdlib=libc++ -fuse-ld=lld --end-no-unused-arguments -O1 -g -gcodeview -c reduced.c
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'reduced.c'.
4. Running pass 'ARM Assembly Printer' on function '@transpose_M_win5'
#0 0x00007f85c8ffeeff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0x88aeff)
#1 0x00007f85c8ffcf2c llvm::sys::CleanupOnSignal(unsigned long) (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0x888f2c)
#2 0x00007f85c8f06457 llvm::CrashRecoveryContext::HandleExit(int) (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0x792457)
#3 0x00007f85c8ff49c2 llvm::sys::Process::Exit(int, bool) (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0x8809c2)
#4 0x0000561f6dbd3f66 (/opt/llvm-mingw/bin/clang+0x12f66)
#5 0x00007f85c8f195ca llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0x7a55ca)
#6 0x00007f85cae39b6d llvm::MCRegisterInfo::getCodeViewRegNum(llvm::MCRegister) const (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0x26c5b6d)
#7 0x00007f85c9c1fb24 (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0x14abb24)
#8 0x00007f85c9c2f665 (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0x14bb665)
#9 0x00007f85c9c33245 (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0x14bf245)
#10 0x00007f85c9ba458b llvm::DebugHandlerBase::endFunction(llvm::MachineFunction const*) (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0x143058b)
#11 0x00007f85c9b96619 llvm::AsmPrinter::emitFunctionBody() (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0x1422619)
#12 0x00007f85cb6a3e93 (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0x2f2fe93)
#13 0x00007f85c94f04a0 (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0xd7c4a0)
#14 0x00007f85c9199c4a llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0xa25c4a)
#15 0x00007f85c9199dd9 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0xa25dd9)
#16 0x00007f85c919b1a0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0xa271a0)
#17 0x00007f85cf6cd9f0 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) (/opt/llvm-mingw/bin/../lib/libclang-cpp.so.17git+0x1e5f9f0)
#18 0x00007f85cfb58709 (/opt/llvm-mingw/bin/../lib/libclang-cpp.so.17git+0x22ea709)
#19 0x00007f85ce28a039 clang::ParseAST(clang::Sema&, bool, bool) (/opt/llvm-mingw/bin/../lib/libclang-cpp.so.17git+0xa1c039)
#20 0x00007f85cfb5785d clang::CodeGenAction::ExecuteAction() (/opt/llvm-mingw/bin/../lib/libclang-cpp.so.17git+0x22e985d)
#21 0x00007f85d06d70f1 clang::FrontendAction::Execute() (/opt/llvm-mingw/bin/../lib/libclang-cpp.so.17git+0x2e690f1)
#22 0x00007f85d0657303 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/llvm-mingw/bin/../lib/libclang-cpp.so.17git+0x2de9303)
#23 0x00007f85d076dde3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/llvm-mingw/bin/../lib/libclang-cpp.so.17git+0x2effde3)
#24 0x0000561f6dbd538c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/llvm-mingw/bin/clang+0x1438c)
#25 0x0000561f6dbce84d (/opt/llvm-mingw/bin/clang+0xd84d)
#26 0x00007f85d028241d (/opt/llvm-mingw/bin/../lib/libclang-cpp.so.17git+0x2a1441d)
#27 0x00007f85c8f06347 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/llvm-mingw/bin/../lib/libLLVM-17git.so+0x792347)
#28 0x00007f85d02828bc (/opt/llvm-mingw/bin/../lib/libclang-cpp.so.17git+0x2a148bc)
#29 0x00007f85d024798e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/llvm-mingw/bin/../lib/libclang-cpp.so.17git+0x29d998e)
#30 0x00007f85d024835d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/llvm-mingw/bin/../lib/libclang-cpp.so.17git+0x29da35d)
#31 0x00007f85d025446c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/llvm-mingw/bin/../lib/libclang-cpp.so.17git+0x29e646c)
#32 0x0000561f6dbd3121 clang_main(int, char**, llvm::ToolContext const&) (/opt/llvm-mingw/bin/clang+0x12121)
#33 0x0000561f6dbcdfc5 main (/opt/llvm-mingw/bin/clang+0xcfc5)
#34 0x00007f85c83c0083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#35 0x0000561f6dbce00e _start (/opt/llvm-mingw/bin/clang+0xd00e)
```
### `reduced.c`
```c
#include <arm_neon.h>
int64x2_t aom_vtrn2q_s64(int64x2_t a, int64x2_t b) {
return vcombine_s64(vget_high_s64(a), vget_high_s64(b));
}
void transpose_M_win5(int64_t *M, int64_t *M_trn) {
int64x2_t row23 = vld1q_s64(M_trn);
int64x2_t row33 = vld1q_s64(M_trn + 3);
vst1q_s64(M, aom_vtrn2q_s64(row23, row33));
}
```
### Additional info
Can also be reproduced by compiling either libwebp or aom from source.
<details>
<summary>Details</summary>
```Dockerfile
# Build with:
# docker build --build-arg ARCH=armv7 -t llvm-mingw .
# docker run --rm llvm-mingw tar -cf - /packaging | tar -xvf -
FROM mstorsjo/llvm-mingw:latest
# Supported architectures: x86_64, i686, aarch64 and armv7
ARG ARCH=armv7
# Install git
RUN apt-get update -qq && \
apt-get install -qqy --no-install-recommends git && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
WORKDIR /build
# Clone libwebp
RUN git clone --depth 1 --recursive https://chromium.googlesource.com/webm/libwebp
# Clone aom
RUN git clone --depth 1 --recursive https://aomedia.googlesource.com/aom
# Compiler flags
ENV \
CFLAGS="-g -gcodeview" \
CXXFLAGS="-g -gcodeview" \
LDFLAGS="-Wl,--pdb="
WORKDIR /build/libwebp/build-$ARCH
# Cross-compile libwebp for Windows
RUN cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="/packaging" \
-DCMAKE_C_COMPILER=$ARCH-w64-mingw32-clang \
-DCMAKE_CXX_COMPILER=$ARCH-w64-mingw32-clang++ \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_SYSTEM_PROCESSOR=$ARCH \
.. && \
cmake --build . -- -j$(nproc) && \
cmake --install .
WORKDIR /build/aom/build-$ARCH
# Cross-compile aom for Windows
RUN cmake \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_DOCS=OFF \
-DENABLE_TESTDATA=OFF \
-DENABLE_TOOLS=OFF \
-DENABLE_EXAMPLES=OFF \
-DCONFIG_AV1_HIGHBITDEPTH=0 \
-DCONFIG_WEBM_IO=0 \
-DCONFIG_RUNTIME_CPU_DETECT=0 \
-DCMAKE_INSTALL_PREFIX="/packaging" \
-DCMAKE_C_COMPILER=$ARCH-w64-mingw32-clang \
-DCMAKE_CXX_COMPILER=$ARCH-w64-mingw32-clang++ \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_SYSTEM_PROCESSOR=$ARCH \
.. && \
cmake --build . -- -j$(nproc) && \
cmake --install .
```
</details>
/cc @mstorsjo
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1zm7zy_zTkRoMHBOblIheOX9qckzQZ20-fnitGSALrKUiuJOzk2_9HgG3kOE3a5pyr_0wnNdJq97er1e6KBSnFSk7ptTO-ccazK9TojZDX3yvKFGq-06tckOdrBwbdP7CkWykcb-Z4k-7vmipNCdgzvQF3d1_vgR-PvJHnSuyPhnRO5HX_sOBKVLQfhSEgAn-nEsiGA9eVNXB3wIGhA5PtnjgwdYKJAxfSyAXuHpx-Mw1qpYVU_wgHLqpqV7s14-XeCSYV0lRpgGS9i919FHYTAXRxhXgJ3AcfuCVwSywI3TG6By4GkpIGUzLCHbICaVQBKqWQTjDpfgDGQY7wd8qJGWv4dy72HBy5SFoypakEMz-bwY7P4918spoD1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