Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[x86_64] Backend Crash due to Scheduling Failure #63790

Open
HazyFish opened this issue Jul 10, 2023 · 3 comments
Open

[x86_64] Backend Crash due to Scheduling Failure #63790

HazyFish opened this issue Jul 10, 2023 · 3 comments
Labels
backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@HazyFish
Copy link
Contributor

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

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

*** 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
@HazyFish
Copy link
Contributor Author

@DataCorrupted

@EugeneZelenko EugeneZelenko added backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Jul 10, 2023
@llvmbot
Copy link
Member

llvmbot commented Jul 10, 2023

@llvm/issue-subscribers-backend-x86

@topperc
Copy link
Collaborator

topperc commented Jul 13, 2023

Looks like we ended up with a TokenFactor between two nodes that need to be glued together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

4 participants