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

    <tr>
        <th>Summary</th>
        <td>
            `clangtk` crashes at llvm::SelectionDAGISel::SelectInlineAsmMemoryOperands
        </td>
    </tr>

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

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

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

<pre>
    The following code triggers a crash when compiled with `clangtk`:

```
struct {
  int c, b, *e;
} a;

void foo() {
  asm volatile("" : "=rm"(a) : "0"(1));
}
```

This issue can be verified by visiting the following link: https://gcc.godbolt.org/z/3qs86xsP6.

Here's the compiler's output (copied from gcc.godbolt.org):
```
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 'X86 DAG->DAG Instruction Selection' on function '@foo'
 #0 0x0000560ec1ebbb9f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3616b9f)
 #1 0x0000560ec1eb9bcc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3614bcc)
 #2 0x0000560ec1e09008 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f7c25cad420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x0000560ec2eed058 llvm::SelectionDAGISel::SelectInlineAsmMemoryOperands(std::vector<llvm::SDValue, std::allocator<llvm::SDValue>>&, llvm::SDLoc const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4648058)
 #5 0x0000560ec2eed56c llvm::SelectionDAGISel::Select_INLINEASM(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x464856c)
 #6 0x0000560ec2eedc4c llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4648c4c)
 #7 0x0000560ec0b5915a (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) X86ISelDAGToDAG.cpp:0:0
 #8 0x0000560ec2ee8147 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4643147)
 #9 0x0000560ec2ef4d19 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/clang+0x464fd19)
#10 0x0000560ec2ef86ed llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x46536ed)
#11 0x0000560ec2ef9e76 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#12 0x0000560ec0b62bb5 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#13 0x0000560ec132ef10 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#14 0x0000560ec184dc7a llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2fa8c7a)
#15 0x0000560ec184de09 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2fa8e09)
#16 0x0000560ec184e9f0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x2fa99f0)
#17 0x0000560ec212c4b0 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)
#18 0x0000560ec303a68c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x479568c)
#19 0x0000560ec440a139 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b65139)
#20 0x0000560ec3039745 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4794745)
#21 0x0000560ec291dbb1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x4078bb1)
#22 0x0000560ec28a18b3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3ffc8b3)
#23 0x0000560ec29fcae3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4157ae3)
#24 0x0000560ebf74030c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xe9b30c)
#25 0x0000560ebf73ba0f ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#26 0x0000560ec26fe2dd 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
#27 0x0000560ec1e09487 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3564487)
#28 0x0000560ec26fe51c 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
#29 0x0000560ec26c5f5e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e20f5e)
#30 0x0000560ec26c692d 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)
#31 0x0000560ec26d0ffc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e2bffc)
#32 0x0000560ebf73df0f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xe98f0f)
#33 0x0000560ebf63b255 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xd96255)
#34 0x00007f7c2575b083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#35 0x0000560ebf737cee _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xe92cee)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWktz46ja_jXKhrILofsiC7cd92SqezrVzjc1OxdCr2S-SKABlMv59aeQZFs4Tqen43M2p6rbseEFHh7eKxLVmlcC4NqLPnnR6op2ZifV9RMHZaS4ymXxcn2_A1TKupZPXFSIyQKQUbyqQGlEEVNU79DTDgRisml5DQV64maHvBizmorKPHgx9oKFh1ce3n_GePzX_9RGdcwgL_k0_EaIC4OYR5Yotx8eWYAXjJ1eskL0-Kv_fJS8QKWUHkk9kk0norpBj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