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

LLVM ERROR: Error while trying to spill X9 from class GPR64: Cannot scavenge register without an emergency spill slot! #63358

Closed
chfast opened this issue Jun 16, 2023 · 7 comments

Comments

@chfast
Copy link
Member

chfast commented Jun 16, 2023

LLVM ERROR: Error while trying to spill X8 from class GPR64: Cannot scavenge register without an emergency spill slot!
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 <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'Prologue/Epilogue Insertion & Frame Finalization' on function '@f'
 #0 0x000055b4a401efbf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3586fbf)
 #1 0x000055b4a401c714 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f4a1540a420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f4a14ed700b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f4a14eb6859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x000055b4a126fa6a llvm::SuffixTree::insertLeaf(llvm::SuffixTreeInternalNode&, unsigned int, unsigned int) (.cold) SuffixTree.cpp:0:0
 #6 0x000055b4a34b65a5 llvm::RegScavenger::spill(llvm::Register, llvm::TargetRegisterClass const&, int, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2a1e5a5)
 #7 0x000055b4a34b6e21 llvm::RegScavenger::scavengeRegisterBackwards(llvm::TargetRegisterClass const&, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, bool, int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2a1ee21)
 #8 0x000055b4a34b7e51 scavengeFrameVirtualRegsInBlock(llvm::MachineRegisterInfo&, llvm::RegScavenger&, llvm::MachineBasicBlock&) RegisterScavenging.cpp:0:0
 #9 0x000055b4a34b828b llvm::scavengeFrameVirtualRegs(llvm::MachineFunction&, llvm::RegScavenger&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2a2028b)
#10 0x000055b4a341cfb8 (anonymous namespace)::PEI::runOnMachineFunction(llvm::MachineFunction&) PrologEpilogInserter.cpp:0:0
#11 0x000055b4a32ad8ce llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#12 0x000055b4a38443f1 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2dac3f1)
#13 0x000055b4a3844639 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2dac639)
#14 0x000055b4a3844eb2 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2daceb2)
#15 0x000055b4a132c744 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
target triple = "aarch64-unknown-linux-gnu"

define i32 @f(ptr %A, i64 %LGV4, i64 %LGV2, i1 %B3, ptr %G, ptr %G1, double %LGV5, ptr %G12, i16 %LGV3, i64 %L10, i1 %B4, ptr %G.1, ptr %G.3, i64 %B8, ptr %G7, ptr %A7, ptr %A13, i1 %C8, ptr %A9, ptr %G.10, ptr %G.11, ptr %G.12) {
BB:
  %A5 = alloca i1, i32 0, align 1
  %G8 = getelementptr i16, ptr %A5, i16 256
  br label %BB1

BB1:                                              ; preds = %BB1, %BB
  %LGV8 = load i64, ptr null, align 4
  %B19 = urem i64 %LGV8, 9223372036854775807
  %C2 = fcmp ugt double %LGV5, 0x7FF0000000000000
  %RP19 = alloca i32, i32 0, align 4
  %B15 = urem i64 %LGV8, %L10
  %B5 = srem i64 %B19, %LGV2
  store double 1.000000e+00, ptr %A, align 8
  store i1 %B4, ptr %G.1, align 1
  store i64 %B5, ptr %G8, align 4
  store i16 %LGV3, ptr %G.3, align 2
  store i64 %LGV4, ptr %G7, align 4
  store i64 %B8, ptr %A7, align 4
  store float 0.000000e+00, ptr %A13, align 4
  store i1 %C8, ptr %G12, align 1
  store i1 %B3, ptr %G.10, align 1
  store i8 0, ptr %A9, align 1
  store i1 true, ptr %G, align 1
  store i64 %B15, ptr %G1, align 4
  store i64 0, ptr %G.11, align 4
  store i1 %C2, ptr %G.12, align 1
  br label %BB1
}

https://godbolt.org/z/on75qaP41

May be related to #63357.

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 16, 2023

@llvm/issue-subscribers-backend-aarch64

@chfast
Copy link
Member Author

chfast commented Jun 22, 2023

I've reduced the test case.

@Long5hot
Copy link
Contributor

I'd like to work on this issue..

@Long5hot Long5hot self-assigned this Jul 24, 2023
@chfast
Copy link
Member Author

chfast commented Jul 24, 2023

One more case.

define i32 @f(ptr %A12, ptr %G.9, ptr %G.7, ptr %A, i64 %LGV4, i64 %LGV2, ptr %G, ptr %RP, ptr %G1, i1 %B4, ptr %G.1, ptr %A7, ptr %A5, i1 %C1, ptr %A13, i1 %C8) {
BB:
  %A55 = alloca i1, i32 0, align 1
  %G8 = getelementptr i16, ptr %A55, i16 256
  br label %BB1

BB1:                                              ; preds = %BB1, %BB
  %B5 = srem i64 1, %LGV2
  store double 1.000000e+00, ptr %A, align 8
  store i1 %B4, ptr %G.1, align 1
  store i64 %B5, ptr %G8, align 4
  store i16 0, ptr %G.7, align 2
  store i64 %LGV4, ptr %A12, align 4
  store i64 0, ptr %A7, align 4
  store i1 false, ptr %G.9, align 1
  store i1 %C8, ptr %RP, align 1
  store i1 %C1, ptr %A13, align 1
  store i8 1, ptr %A5, align 1
  store i1 false, ptr %G1, align 1
  store i64 0, ptr %G, align 4
  br label %BB1
}

@Long5hot
Copy link
Contributor

Long5hot commented Jul 24, 2023

Thanks for reduced testCase..

@chfast
Copy link
Member Author

chfast commented Jul 24, 2023

define i32 @f(ptr %G11, ptr %G.5, ptr %A, i1 %C6, ptr %G.4, ptr %A12, ptr %A7, ptr %G.10, ptr %G.9, i64 %LGV4, i64 %LGV2, i64 %L8, ptr %G14, i16 %LGV3, i16 %L5, i16 %L7, i1 %C8) {
BB:
  %A57 = alloca i1, i32 0, align 1
  %G8 = getelementptr i16, ptr %A57, i16 256
  %B16 = urem i16 %LGV3, %L5
  %B5 = mul i64 %LGV4, %LGV2
  store i64 %B5, ptr %G8, align 4
  store i16 %L7, ptr %G14, align 2
  store i64 %L8, ptr %G.9, align 4
  store i64 %LGV4, ptr %A7, align 4
  store i1 true, ptr %G.5, align 1
  store float 0.000000e+00, ptr %A, align 4
  store i1 %C8, ptr %G.10, align 1
  store i16 %B16, ptr %G.4, align 2
  store i64 %LGV2, ptr %G11, align 4
  store float 0.000000e+00, ptr %A12, align 4
  store i1 %C6, ptr %G11, align 1
  ret i32 0
}

@Long5hot
Copy link
Contributor

Can we close this issue, Failure seems to fix now..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants