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
[Subreg liveness] Assertion `INext != E && "Must have following segment"' failed #40717
Comments
Ping! Saw this again this week in testing. Original test case still failing. |
3 similar comments
Ping! Saw this again this week in testing. Original test case still failing. |
Ping! Saw this again this week in testing. Original test case still failing. |
Ping! Saw this again this week in testing. Original test case still failing. |
Thanks Jonas for the reminder. I’ll try to look at it this week. |
I can reproduce the problem, looking. |
At first glance, I'd say the problem is that we have a subrange that is dead, but we fail to see that and thus try to extend the live-range to the next segment, which, since it is dead, does not exist. The problematic sequence is this one: Here subreg_h32 is never used, yet the (sub)live-range is not mark as dead: Thus, when we try to update 176r to the new index, we fail to see that 176r was the last use and look for the next segment. |
For the record the full live-interval for %5 at the time of the assert looks like this: Notice how L00000001 goes from 160r to 176r, whereas at this point, there is no instruction at 176r. This happens because L00000001 is actually not used by what was at 176r and thus doesn't get updated when we move it around. Anyway, that's a side problem in the sense that if that lane was marked as dead to beginning with, the use index wouldn't be here, so no update would be required. Given those live-ranges are created during register coalescing, I am going to look at why we don't mark that lane as dead. |
Tentative fix |
Note to myself: would be better if I can mark the dead lanes in refineSubRanges. |
I'll go with the tentative fix I've already attached.
We could reuse LiveIntervals::shrinkToUses as well after the IR has been updated, but right now, the rematerialization doesn't call that function so, same problem: potential increase in compile time. Given we know specifically what needs to happen for the remat case, that compile time increase is not really worth it. |
Should be fixed with: |
@qcolombet: Thank you for fixing this :-) I see that #34922 now also seems fixed ("Live segment doesn't end at a valid instruction"). Do you believe your fix also handles this assertion? I saw a new test this week which also went away with your latest patch included... |
Yeah, that would make sense that this patch fixes a “doesn’t end at a valid instruction“ assert. Happy to help! Thanks for your patience. |
Extended Description
llc -mcpu=z13 -O3 -o out.s -misched=ilpmin -systemz-subreg-liveness tc_musthavefollseg.ll
llc: llvm/llvm-dev/lib/CodeGen/LiveIntervals.cpp:1142: void llvm::LiveIntervals::HMEditor::handleMoveDown(llvm::LiveRange&)
: Assertion `INext != E && "Must have following segment"' failed.
Stack dump:
0. Program arguments: llc -mcpu=z13 -O3 -o out.s -misched=ilpmin -systemz-subreg-liveness tc_musthavefollseg.ll
2. Running pass 'Machine Instruction Scheduler' on function '@main'
...
#9 0x000002aa3522b370 llvm::LiveIntervals::HMEditor::updateRange(llvm::LiveRange&, unsigned int, llvm::LaneBitmask)
#10 0x000002aa3522bae4 llvm::LiveIntervals::HMEditor::updateAllRanges(llvm::MachineInstr*)
#11 0x000002aa3522eb50 llvm::LiveIntervals::handleMove(llvm::MachineInstr&, bool)
#12 0x000002aa353563d4 llvm::ScheduleDAGMI::moveInstruction(llvm::MachineInstr*, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>)
...
The text was updated successfully, but these errors were encountered: