-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[RISCV] VSETVLI pass crashes due to "Cannot create empty or backwards segment" error #141907
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
Comments
@llvm/issue-subscribers-bug Author: Piyou Chen (BeMg)
The error message
```
llc: llvm-project/llvm/include/llvm/CodeGen/LiveInterval.h:172: llvm::LiveRange::Segment::Segment(SlotIndex, SlotIndex, VNInfo *): Assertion `S < E && "Cannot create empty or backwards segment"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: llvm-project/build/bin/llc reduced.ll -print-after-all
1. Running pass 'Function Pass Manager' on module 'reduced.ll'.
2. Running pass 'RISC-V Insert VSETVLI pass' on function '@silk_resampler_down2_3'
#0 0x0000556207b594d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llvm-project/build/bin/llc+0x21e24d8)
#1 0x0000556207b5702e llvm::sys::RunSignalHandlers() (llvm-project/build/bin/llc+0x21e002e)
#2 0x0000556207b59bf6 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007fce399d1cf0 __restore_rt (/lib64/libpthread.so.0+0x12cf0)
#4 0x00007fce38451acf raise (/lib64/libc.so.6+0x4eacf)
#5 0x00007fce38424ea5 abort (/lib64/libc.so.6+0x21ea5)
#6 0x00007fce38424d79 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d79)
#7 0x00007fce3844a426 (/lib64/libc.so.6+0x47426)
#8 0x00005562063189cf (llvm-project/build/bin/llc+0x9a19cf)
#9 0x0000556206c7fb7b llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (llvm-project/build/bin/llc+0x1308b7b)
#10 0x00005562071fd555 llvm::FPPassManager::runOnFunction(llvm::Function&) (llvm-project/build/bin/llc+0x1886555)
#11 0x0000556207205292 llvm::FPPassManager::runOnModule(llvm::Module&) (llvm-project/build/bin/llc+0x188e292)
#12 0x00005562071fdda1 llvm::legacy::PassManagerImpl::run(llvm::Module&) (llvm-project/build/bin/llc+0x1886da1)
#13 0x00005562061e4c85 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#14 0x00005562061e228d main (llvm-project/build/bin/llc+0x86b28d)
#15 0x00007fce3843dd85 __libc_start_main (/lib64/libc.so.6+0x3ad85)
#16 0x00005562061de4de _start (llvm-project/build/bin/llc+0x8674de)
Aborted
```
I think is relate to
The This bug could be solved by replacing those statements with
|
@llvm/issue-subscribers-backend-risc-v Author: Piyou Chen (BeMg)
The error message
```
llc: llvm-project/llvm/include/llvm/CodeGen/LiveInterval.h:172: llvm::LiveRange::Segment::Segment(SlotIndex, SlotIndex, VNInfo *): Assertion `S < E && "Cannot create empty or backwards segment"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: llvm-project/build/bin/llc reduced.ll -print-after-all
1. Running pass 'Function Pass Manager' on module 'reduced.ll'.
2. Running pass 'RISC-V Insert VSETVLI pass' on function '@silk_resampler_down2_3'
#0 0x0000556207b594d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llvm-project/build/bin/llc+0x21e24d8)
#1 0x0000556207b5702e llvm::sys::RunSignalHandlers() (llvm-project/build/bin/llc+0x21e002e)
#2 0x0000556207b59bf6 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007fce399d1cf0 __restore_rt (/lib64/libpthread.so.0+0x12cf0)
#4 0x00007fce38451acf raise (/lib64/libc.so.6+0x4eacf)
#5 0x00007fce38424ea5 abort (/lib64/libc.so.6+0x21ea5)
#6 0x00007fce38424d79 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d79)
#7 0x00007fce3844a426 (/lib64/libc.so.6+0x47426)
#8 0x00005562063189cf (llvm-project/build/bin/llc+0x9a19cf)
#9 0x0000556206c7fb7b llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (llvm-project/build/bin/llc+0x1308b7b)
#10 0x00005562071fd555 llvm::FPPassManager::runOnFunction(llvm::Function&) (llvm-project/build/bin/llc+0x1886555)
#11 0x0000556207205292 llvm::FPPassManager::runOnModule(llvm::Module&) (llvm-project/build/bin/llc+0x188e292)
#12 0x00005562071fdda1 llvm::legacy::PassManagerImpl::run(llvm::Module&) (llvm-project/build/bin/llc+0x1886da1)
#13 0x00005562061e4c85 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#14 0x00005562061e228d main (llvm-project/build/bin/llc+0x86b28d)
#15 0x00007fce3843dd85 __libc_start_main (/lib64/libc.so.6+0x3ad85)
#16 0x00005562061de4de _start (llvm-project/build/bin/llc+0x8674de)
Aborted
```
I think is relate to
The This bug could be solved by replacing those statements with
|
cc @lukel97 |
Another possible fix.
|
I think this due to both the AVL and defining VL being the same registers when coalescing:
We should probably move the AVL operand up and shrink its live range first, then handle DefReg. The DefReg bit is also incorrectly assuming that DefLI only has one segment 😬 I think I have a fix for this, will post a patch soon |
With EVL tail folding we can end up with vsetvlis where the output vl and the input AVL are the same register. When we try to coalesce it we crashed because we tried to move the def's live interval before the kill's live interval, e.g. in this example: (vn0 def) dead $x0 = PseudoVSETIVLI 1, 192, implicit-def $vl, implicit-def $vtype renamable $v9 = COPY killed renamable $v8 (vn1 def) %23:gprnox0 = PseudoVSETVLI killed (vn0) %23:gprnox0, 197, implicit-def $vl, implicit-def $vtype We would try to move the vn1 def VNInfo up to the previous VSETVLI, in the middle of vn0's segment. However separately, we were also assuming that the vl would only have one definition and thus were just taking the VNInfo from beginIndex(), so we ended up with a backwards segment and got the error "Cannot create empty or backwards segment". This fixes these two issues, the first one by moving the AVL operand + live interval up first, and the second by taking the VNInfo from NextMI's slot index. Fixes llvm#141907
Uh oh!
There was an error while loading. Please reload this page.
The error message
I think is relate to
llvm-project/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
Line 1708 in e2f86b5
The
beginIndex()
value could less thanMISlot
.This bug could be solved by replacing those statements withUpdate: remove and create will make other testcase failure.
The text was updated successfully, but these errors were encountered: