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

    <tr>
        <th>Summary</th>
        <td>
            [x86_64] Backend Crash due to Scheduling Failure
        </td>
    </tr>

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

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

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

<pre>
    ## Description

The following code crashes the `x86_64` backend with scheduling failure.
The problem doesn't exist when targeting `i686`, `aarch64`, or `riscv64`.

## Minimal Reproduction

https://godbolt.org/z/jW31Gc7xh

### Code

```ll
define void @f(ptr %0, i64 %1) {
BB:
  %fps = load <2 x ptr>, ptr %0
  %fp = extractelement <2 x ptr> %fps, i64 %1
  %p = call ptr %fp(i32 42)
  store <2 x ptr> %fps, ptr %p
  ret void
}
```

### Stack Trace

```console
*** Scheduling failed! ***
SU(3): t18: i64,ch,glue = CopyFromReg t16:1, Register:i64 $rax, t16:2

    t13: ch,glue = CopyToReg t11:1, Register:i32 $edi, t9

    t15: ch,glue = CALL64m<Mem:(load (s64))> TargetFrameIndex:i64<0>, TargetConstant:i8<8>, t27, TargetConstant:i32<0>, Register:i16 $noreg, Register:i32 $edi, RegisterMask:Untyped, t43, t13:1

    t16: i64,ch,glue = ADJCALLSTACKUP64 TargetConstant:i64<0>, TargetConstant:i64<0>, t15, t15:1

has not been scheduled!
SU(3): t18: i64,ch,glue = CopyFromReg t16:1, Register:i64 $rax, t16:2

 t13: ch,glue = CopyToReg t11:1, Register:i32 $edi, t9

    t15: ch,glue = CALL64m<Mem:(load (s64))> TargetFrameIndex:i64<0>, TargetConstant:i8<8>, t27, TargetConstant:i32<0>, Register:i16 $noreg, Register:i32 $edi, RegisterMask:Untyped, t43, t13:1

    t16: i64,ch,glue = ADJCALLSTACKUP64 TargetConstant:i64<0>, TargetConstant:i64<0>, t15, t15:1

has successors left!
SU(4): t9: i32 = MOV32ri TargetConstant:i32<42>

has not been scheduled!
SU(4): t9: i32 = MOV32ri TargetConstant:i32<42>

has successors left!
SU(7): t25: ch = MOVAPSmr<Mem:(store (s128) into %stack.0)> TargetFrameIndex:i64<0>, TargetConstant:i8<1>, Register:i64 $noreg, TargetConstant:i32<0>, Register:i16 $noreg, t7, t0

has not been scheduled!
SU(7): t25: ch = MOVAPSmr<Mem:(store (s128) into %stack.0)> TargetFrameIndex:i64<0>, TargetConstant:i8<1>, Register:i64 $noreg, TargetConstant:i32<0>, Register:i16 $noreg, t7, t0

has successors left!
SU(8): t27: i64 = SUBREG_TO_REG TargetConstant:i64<0>, t48, TargetConstant:i32<6>

has not been scheduled!
SU(8): t27: i64 = SUBREG_TO_REG TargetConstant:i64<0>, t48, TargetConstant:i32<6>

has successors left!
SU(9): t48: i32,i32 = AND32ri t45, TargetConstant:i32<1>

has not been scheduled!
SU(9): t48: i32,i32 = AND32ri t45, TargetConstant:i32<1>

has successors left!
SU(10): t45: i32 = EXTRACT_SUBREG t4, TargetConstant:i32<6>

has not been scheduled!
SU(10): t45: i32 = EXTRACT_SUBREG t4, TargetConstant:i32<6>

has successors left!
SU(11): t4: i64,ch = CopyFromReg t0, Register:i64 %1

has not been scheduled!
SU(11): t4: i64,ch = CopyFromReg t0, Register:i64 %1

has successors left!
SU(12): t7: v2i64,ch = MOVAPSrm<Mem:(load (s128) from %ir.0)> t2, TargetConstant:i8<1>, Register:i64 $noreg, TargetConstant:i32<0>, Register:i16 $noreg, t0

has not been scheduled!
SU(12): t7: v2i64,ch = MOVAPSrm<Mem:(load (s128) from %ir.0)> t2, TargetConstant:i8<1>, Register:i64 $noreg, TargetConstant:i32<0>, Register:i16 $noreg, t0

has successors left!
SU(13): t2: i64,ch = CopyFromReg t0, Register:i64 %0

has not been scheduled!
SU(13): t2: i64,ch = CopyFromReg t0, Register:i64 %0

has successors left!
llc: /root/llvm-project/llvm/lib/CodeGen/ScheduleDAG.cpp:435: unsigned int llvm::ScheduleDAG::VerifyScheduledDAG(bool): Assertion `!AnyNotSched' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=x86_64 <source>
1.      Running pass 'Function Pass Manager' on module '<source>'.
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@f'
 #0 0x0000557c0dd5113f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x354913f)
 #1 0x0000557c0dd4e894 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f5a99fc7420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f5a99a9400b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f5a99a73859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007f5a99a73729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007f5a99a84fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x0000557c0d22e88f (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2a2688f)
 #8 0x0000557c0da29731 llvm::ScheduleDAGSDNodes::VerifyScheduledSequence(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3221731)
 #9 0x0000557c0da240ba (anonymous namespace)::ScheduleDAGRRList::Schedule() ScheduleDAGRRList.cpp:0:0
#10 0x0000557c0db184e3 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x33104e3)
#11 0x0000557c0db1bac8 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3313ac8)
#12 0x0000557c0db1d792 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#13 0x0000557c0c4cf8f0 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#14 0x0000557c0cff0fae llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x0000557c0d58afa1 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2d82fa1)
#16 0x0000557c0d58b1e9 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2d831e9)
#17 0x0000557c0d58ba62 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2d83a62)
#18 0x0000557c0b09e624 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#19 0x0000557c0afe6ef6 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x7deef6)
#20 0x00007f5a99a75083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#21 0x0000557c0b094a0e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x88ca0e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWt1y2zjSfRr4BmUVCPD3whe0ZHnyffbEZTnZ3LlAsilxQgJcAEzkefotgKQsyooTZzQzVTtbZVsyAJ4-p9FoAC1xrau1ALhAwSUKFme8MxupLn7hvz8tK705y2TxdIEoQ5ThBehcVa2ppEBkgUja_33YAC5lXcuvlVjjXBaAc8X1BjQ2G8AoJNs4fAx9FBKc8fwziAJ_rcwG63wDRVfbp0pe1Z2C2TNiq2RWQ4MLCVogGhkM20ob_HUDAhuu1mDsgygkVRiHKCSIzu1_nKt844zZBqlsm6p0_sW1zfaJD7JuK1E1vMb30CpZdPmhvo0xrUYsRXSJ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