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

    <tr>
        <th>Summary</th>
        <td>
            __asm__ causes crash with -fms-hotpatch
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Found another `-fms-hotpatch` problem:

```c++
void test(void) {
        __asm__ __volatile__("nop" ::: "memory");
}
```

When compiled at `-O1` or higher, with `-fms-hotpatch`, it crashes the compiler ([godbolt link](https://gcc.godbolt.org/z/fE1nK77e7)):
```
PATCHABLE_OP 2, 1, &nop, 25, 12, 12, 12, !14, implicit-def dead early-clobber $df, implicit-def early-clobber $fpsw, implicit-def dead early-clobber $eflags, debug-location !13; example.cpp:2:2
unknown operand type
UNREACHABLE executed at /root/llvm-project/llvm/lib/Target/X86/X86MCInstLower.cpp:334!
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-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O1 -fno-optimize-sibling-calls -fms-hotpatch <source>
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '<source>'.
4.      Running pass 'X86 Assembly Printer' on function '@_Z4testv'
 #0 0x00000000037de8b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x37de8b8)
 #1 0x00000000037dc59c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x37dc59c)
 #2 0x0000000003724de8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f2e03c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f2e03c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007f2e03c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007f2e03c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000000000373007a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x373007a)
 #8 0x00000000022e758c (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x22e758c)
 #9 0x00000000022e7b2a llvm::X86AsmPrinter::LowerPATCHABLE_OP(llvm::MachineInstr const&, (anonymous namespace)::X86MCInstLower&) X86MCInstLower.cpp:0:0
#10 0x00000000022ea060 llvm::X86AsmPrinter::emitInstruction(llvm::MachineInstr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x22ea060)
#11 0x00000000046698af llvm::AsmPrinter::emitFunctionBody() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46698af)
#12 0x00000000022dc4c1 llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x22dc4c1)
#13 0x0000000002bd0901 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#14 0x00000000031901e9 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x31901e9)
#15 0x0000000003190421 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3190421)
#16 0x0000000003190c62 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3190c62)
#17 0x0000000003a57296 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0
#18 0x0000000003a57621 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>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a57621)
#19 0x000000000405e98c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x405e98c)
#20 0x0000000005fd6149 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5fd6149)
#21 0x000000000405dd28 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x405dd28)
#22 0x00000000042cae49 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42cae49)
#23 0x0000000004249f7e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4249f7e)
#24 0x00000000043aa64e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43aa64e)
#25 0x0000000000c05476 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc05476)
#26 0x0000000000bfcd3a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x000000000409ee69 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
#28 0x0000000003725294 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3725294)
#29 0x000000000409f45f 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
#30 0x00000000040675c5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40675c5)
#31 0x000000000406802d 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+++0x406802d)
#32 0x000000000406ff25 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x406ff25)
#33 0x0000000000c028fc clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc028fc)
#34 0x0000000000afb5f1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xafb5f1)
#35 0x00007f2e03c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x00007f2e03c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x0000000000bfc81e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbfc81e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
````
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWltzrLgR_jX4RcUUCIbLgx_GY0_Obs6JXcfeZCsvlBCCUSwkIgl7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