<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69201>69201</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang: fatal error: error in backend: Cannot emit physreg copy instruction
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
connglli
</td>
</tr>
</table>
<pre>
Compiler explorer: https://godbolt.org/z/fTrKEjrTx.
The following program `small.c` triggers a crash in clang-18:
``` sh
% cat small.c
void f(int x) {
register int s3 asm("19") = x;
asm("" : : "r"(s3));
}
% clang -O0
fatal error: error in backend: Cannot emit physreg copy instruction
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/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 <source>
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '<source>'.
4. Running pass 'Post-RA pseudo instruction expansion pass' on function '@f'
#0 0x000000000372f498 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372f498)
#1 0x000000000372d15c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372d15c)
#2 0x0000000003675fe6 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3675fe6)
#3 0x00000000037244ae llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37244ae)
#4 0x0000000000bed7da LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
#5 0x0000000003680983 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3680983)
#6 0x0000000003680ae8 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3680ae8)
#7 0x00000000024e12b5 llvm::X86InstrInfo::copyPhysReg(llvm::MachineBasicBlock&, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::DebugLoc const&, llvm::MCRegister, llvm::MCRegister, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x24e12b5)
#8 0x0000000002d7e248 llvm::TargetInstrInfo::lowerCopy(llvm::MachineInstr*, llvm::TargetRegisterInfo const*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x2d7e248)
#9 0x0000000002e73b97 (anonymous namespace)::ExpandPostRA::runOnMachineFunction(llvm::MachineFunction&) ExpandPostRAPseudos.cpp:0:0
#10 0x0000000002b04411 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#11 0x00000000030b2af9 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x30b2af9)
#12 0x00000000030b2d31 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x30b2d31)
#13 0x00000000030b3552 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x30b3552)
#14 0x00000000039a3c02 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) BackendUtil.cpp:0:0
#15 0x00000000039a40a9 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/compiler-explorer/clang-assertions-trunk/bin/clang+0x39a40a9)
#16 0x000000000499c34f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499c34f)
#17 0x0000000005ea1529 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea1529)
#18 0x000000000499b538 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499b538)
#19 0x00000000041fefa9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41fefa9)
#20 0x000000000418044e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x418044e)
#21 0x00000000042de12e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42de12e)
#22 0x0000000000befa56 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbefa56)
#23 0x0000000000be731a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#24 0x0000000003fdc649 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#25 0x0000000003675f24 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3675f24)
#26 0x0000000003fdcc3f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#27 0x0000000003fa4e05 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa4e05)
#28 0x0000000003fa586d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa586d)
#29 0x0000000003fad795 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fad795)
#30 0x0000000000becefc clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbecefc)
#31 0x0000000000ae7091 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xae7091)
#32 0x00007f3aceb41083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#33 0x0000000000be6dfe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbe6dfe)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
```
Clang version:
```
clang version 18.0.0 (https://github.com/llvm/llvm-project.git ab737a86993bc7bf92cbb9d51f47f8825a717333)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
Compiler returned: 0
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWk1z4zbS_jX0BSUVCVL8OPggy9abyTtT47Kd1N5UINikkAEBLgDa0v76LfBDImh5Jtko2cNO2WMJbDaefrrR3QBJtGaVALj1Vnfe6v6GtGYv1S2VQlScs5tcFsfbjawbxkEhODRcKlBeuEZ7YxrthWsPbz28rWSRS26WUlUe3v7Lw9vyRf3_w2_q5bD0_HvPX_f_v-wBlZJz-cZEhRolK0Vq5MW-rgnnS-rFPjKKVRUojQiiiug9YgJRTkS1CFI74USdF_v9D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