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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Assertion `MI->getOpcode() == TargetOpcode::COPY && "start of copy chain MUST be COPY"' failed.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:X86,
            crash-on-valid,
            llvm:SelectionDAG,
            clang:frontend:fuzzer
      </td>
    </tr>

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

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

<pre>
    **This testcase is generated by a fuzzer.**

Compiler Explorer: [https://godbolt.org/z/EWbqv8hz7](https://godbolt.org/z/EWbqv8hz7)

This valid code will crash on Clang Assertion Trunk:
```cpp
int foo(int x) {
    float y;
    asm goto("" : "=r"(y) : "r"(x) : : err);
err:
    return -1;
}
```

It seems that this goes back to clang-17.

Stack dump:
```
clang++: /root/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:12629: llvm::Register FollowCopyChain(llvm::MachineRegisterInfo&, llvm::Register): Assertion `MI->getOpcode() == TargetOpcode::COPY && "start of copy chain MUST be COPY"' failed.
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 -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <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 '@_Z3fooi'
 #0 0x0000000003bb5bd8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bb5bd8)
 #1 0x0000000003bb389c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bb389c)
 #2 0x0000000003b00e88 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007bf2eda42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007bf2eda969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007bf2eda42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007bf2eda287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007bf2eda2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007bf2eda39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x0000000004dcbfe8 llvm::SelectionDAGBuilder::visitCallBrLandingPad(llvm::CallInst const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4dcbfe8)
#10 0x0000000004df3cb4 llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst const&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4df3cb4)
#11 0x0000000004dfd370 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4dfd370)
#12 0x0000000004e1152f llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e1152f)
#13 0x0000000004e9d5c8 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, bool&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e9d5c8)
#14 0x0000000004e9e2b6 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e9e2b6)
#15 0x0000000004e9f830 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e9f830)
#16 0x0000000004e9056f llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e9056f)
#17 0x0000000002f1d149 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#18 0x0000000003519270 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3519270)
#19 0x0000000003519621 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3519621)
#20 0x0000000003519ed7 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3519ed7)
#21 0x0000000003e63ea5 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+++0x3e63ea5)
#22 0x000000000452a1ce clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x452a1ce)
#23 0x000000000666f07c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x666f07c)
#24 0x000000000452a5b8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x452a5b8)
#25 0x00000000047e4ce9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47e4ce9)
#26 0x00000000047637de clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47637de)
#27 0x00000000048ca48e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48ca48e)
#28 0x0000000000cddb4f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcddb4f)
#29 0x0000000000cd585a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#30 0x000000000456e2c9 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
#31 0x0000000003b01334 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b01334)
#32 0x000000000456e8bf 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
#33 0x00000000045341bd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45341bd)
#34 0x00000000045352ad 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+++0x45352ad)
#35 0x000000000453cbd5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453cbd5)
#36 0x0000000000cdaa1f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdaa1f)
#37 0x0000000000ba9b14 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xba9b14)
#38 0x00007bf2eda29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#39 0x00007bf2eda29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#40 0x0000000000cd530e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd530e)
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/eJzkWl2T2jjW_jXuGxWULX9gX_QFDU0mU0mlK_S87-zeULJ8bDQxkkeSO5BfvyXZgOWmk_RWM7NbO5VJQB9Hz3N0viRElGIVB7j14jsvXt6QVm-FvD2wPwiP0ii-yUVxuPXw3MPzxy1TSIPSlChATKEKOEiioUD5ARFUtt--gZx2gz1_6fn93wuxa1gNEt3vm1pIkF44R158t9W6UV449_DKw6tKFLmo9VTIysOrbx5e3f9__udTuv028-Klh9OfH46z4fIW9xOpWYGoKAB9ZXWNqCRqiwRHi5rwCs2VAqmZ4OhRtvyLWaWTkPjdH9o0XQvjGpVCeDg1n_YezpA3u-v6EEKorAXR6OCFgzaidqgS2kzyMPYwRlYDGHvhUtqW9GAFda190_7UFM4RSGloHaWar0eMZgUJupUcTYLTCG-2HFEY6uS9Rgpgp5DeEo200VAlQKGc0C9IC0SNVibBbDqctNamt2h3zXP9dF_tNA_fmT-Wy0oKoT28quun3aSR4g-gx6_mH5Z7eLUQBbwD7uHVGmqgZheW83ejr3ctqwuQU7MP4TzAiVHGHFlB4dwL55-hYkqDRCtR1-LrQjSHxZYw7uH0POgjoVvG4T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