<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/63028>63028</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clangtk crashes at llvm::X86InstrInfo::copyPhysReg
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          wierton
      </td>
    </tr>
</table>

<pre>
    When compiling below code with `clangtk -O0`, `clangtk` crashes:
```
void f(int x) {
  if (x) {
    register int a1 asm("18") = x;
 register int a2 asm("19") = x;
    asm("" : : "r"(a1));
 asm("" : : "r"(a2));
  }
}
```

The output of `clangtk`, (can be verified at the link https://gcc.godbolt.org/z/EzG9zeM4P):
```
<source>:5:9: error: couldn't allocate input reg for constraint '{fpcr}'
    asm("" : : "r"(a1));
        ^
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-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 -xc <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 0x00005620fa4d3b9f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3616b9f)
 #1 0x00005620fa4d1bcc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3614bcc)
 #2 0x00005620fa421597 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3564597)
 #3 0x00005620fa4c97c2 llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x360c7c2)
 #4 0x00005620f7d56d86 (/opt/compiler-explorer/clang-trunk/bin/clang+0xe99d86)
 #5 0x00005620fa42a58a llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x356d58a)
 #6 0x00005620fa42a71e (/opt/compiler-explorer/clang-trunk/bin/clang+0x356d71e)
 #7 0x00005620f9328e5c llvm::X86InstrInfo::copyPhysReg(llvm::MachineBasicBlock&, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::DebugLoc const&, llvm::MCRegister, llvm::MCRegister, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x246be5c)
 #8 0x00005620f9c56fd9 (anonymous namespace)::ExpandPostRA::runOnMachineFunction(llvm::MachineFunction&) ExpandPostRAPseudos.cpp:0:0
 #9 0x00005620f9946f10 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#10 0x00005620f9e65c7a llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2fa8c7a)
#11 0x00005620f9e65e09 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2fa8e09)
#12 0x00005620f9e669f0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2fa99f0)
#13 0x00005620fa7444b0 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-trunk/bin/clang+0x38874b0)
#14 0x00005620fb65268c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x479568c)
#15 0x00005620fca22139 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b65139)
#16 0x00005620fb651745 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4794745)
#17 0x00005620faf35bb1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4078bb1)
#18 0x00005620faeb98b3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3ffc8b3)
#19 0x00005620fb014ae3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4157ae3)
#20 0x00005620f7d5830c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xe9b30c)
#21 0x00005620f7d53a0f ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#22 0x00005620fad162dd 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
#23 0x00005620fa421487 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3564487)
#24 0x00005620fad1651c 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
#25 0x00005620facddf5e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e20f5e)
#26 0x00005620facde92d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e2192d)
#27 0x00005620face8ffc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e2bffc)
#28 0x00005620f7d55f0f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xe98f0f)
#29 0x00005620f7c53255 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xd96255)
#30 0x00007f13160b9083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#31 0x00005620f7d4fcee _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xe92cee)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWVtT4zja_jXmRpWULZ8vuAiBzPRUd0EB37d7l5LlV44WR_JKMoT-9VvygVgmdPcMmb3ZLqBt6ZX0-HmPkojWvBIAl1585cXXF6Q1O6kuXzgoI8VFIcvXy3_sQCAq9w2vuahQAbV8QVSWgF642SEv8WlNRGWe0OLW9xLfw-tJo5f4iCqid6C9cOX5156_skL9T_f6LHmJmIczLgw6eDhHXnrVdyHEGfJwNm9FSEHFtQGF7CASIKL3Hs48jAP7pxMPr9HBC8cx7gA8GZCfHoDQUcbDGHnhqv_FWHVNGQk8nNuftzE_G4DnA5CXXg-kvD247PR_H3eAZGua1iDJXHo7vnFGiUAFoGdQnHEoETHI7ADVXDyhnTFNRz_eeHhTUbqsZFnI2iylqjy8-e7hzc333_Lv8C266_Cd1pQXrrVsFQUvvPHCVeyFKyuLQCmp7AOVbV0KD6cGkbqWlBhAXFjUCirEpEJUCm0UsUrwcOqlV6yhyn47Tj_B-_DPi2_6BkYMqY-wugfEBSoIfQJR2rY1EUIaBHtuULN71RYglc0r4hZg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