This is an archive of the discontinued LLVM Phabricator instance.

RA: Remove assert on empty live intervals
ClosedPublic

Authored by arsenm on Jul 21 2017, 11:34 AM.

Details

Reviewers
MatzeB
kparzysz
Summary

This is possible if there is an undef use when
splitting the vreg during spilling.

Fixes bug 33620.

Diff Detail

Event Timeline

arsenm created this revision.Jul 21 2017, 11:34 AM
qcolombet added inline comments.Jul 21 2017, 1:51 PM
lib/CodeGen/RegAllocBase.cpp
147

If that's empty and legit, I believe we shouldn't try to enqueue it.

arsenm added inline comments.Jul 21 2017, 1:59 PM
lib/CodeGen/RegAllocBase.cpp
147

It still needs to be allocated to a register, otherwise an undef vreg use is left around

MatzeB accepted this revision.Jul 21 2017, 2:35 PM

LGTM.
The following code is obviously able to handle it (as we can have the same situation from non-split intervals where no assert exists). So I guess this was a sanity check on the spiller/splitter, let's hope we are fine without it.

This revision is now accepted and ready to land.Jul 21 2017, 2:35 PM
arsenm closed this revision.Jul 21 2017, 4:57 PM

r308808

qcolombet added inline comments.Jul 21 2017, 5:37 PM
lib/CodeGen/RegAllocBase.cpp
147

The problem IIRC is that I believe later code is not fine with that.
(BTW, you could have waited for the discussion to be over before committing...)

qcolombet added inline comments.Jul 21 2017, 5:52 PM
lib/CodeGen/RegAllocBase.cpp
147

Regardless of the surrounding code working or not in that case, having an empty live-range that needs a register sounds plain wrong to me.

arsenm added inline comments.Jul 21 2017, 5:53 PM
lib/CodeGen/RegAllocBase.cpp
147

Sorry, I had talked to Matthias about this earlier. The assert is also fairly new and was added last year in r279625 with subregister changes.

MatzeB added inline comments.Jul 21 2017, 5:56 PM
lib/CodeGen/RegAllocBase.cpp
147

An empty live range that needs a register looks like this and is valid IMO and the normal code handled it fine in my experiments (but it needs to assign a register obviously):

= USE vreg0<undef>
MatzeB added inline comments.
lib/CodeGen/RegAllocBase.cpp
147

Ah the infamous r279625, let's add Krzysztof to the reviwers.

qcolombet added inline comments.Jul 21 2017, 6:00 PM
lib/CodeGen/RegAllocBase.cpp
147

I am fine with removing the assert. I'm against enqueueing an empty live-range though. More specifically, I am fine with enqueueing it as long as it is valid not to assign it a register.
We have code that makes that assumption (e.g., in last chance recoloring).

MatzeB added inline comments.Jul 21 2017, 6:02 PM
lib/CodeGen/RegAllocBase.cpp
147

We need to enqueu it so it gets a register assigned. I think those empty liveranges will always succedd when we try to assign a register (because they interfer with nothing) so we should never hit the recolring, splitting etc. phases for them.

qcolombet added inline comments.Jul 21 2017, 6:06 PM
lib/CodeGen/RegAllocBase.cpp
147
= USE vreg0<undef>

That's different.
That says we don't care about the value of vreg0 here, not that its live-range is empty.

What I am saying is that I would rather that we come up with a different concept than overloading empty here, because it weakens our ability to find bugs.

qcolombet added inline comments.Jul 21 2017, 6:09 PM
lib/CodeGen/RegAllocBase.cpp
147

We need to enqueu it so it gets a register assigned.

Yes because how we conflates the semantic of empty and need a register. But I don't think that's right.

[...] so we should never hit the recolring[...]

Although that's probably true, each time I see should, I think potential bugs :P

MatzeB added inline comments.Jul 21 2017, 6:11 PM
lib/CodeGen/RegAllocBase.cpp
147

undef operand by construction have no influence on the liverange. They are perfectly valid operands that use vregs, but they have absolutely no effect on the liverange. Hence we end up with an empty liverange. That is just how things work AFAIK.

qcolombet added inline comments.Jul 21 2017, 6:36 PM
lib/CodeGen/RegAllocBase.cpp
147

undef operand by construction have no influence on the liverange. They are perfectly valid operands that use vregs, but they have absolutely no effect on the liverange. Hence we end up with an empty liverange.
That is just how things work AFAIK.

I agree that empty live-range model the right thing.
What I am saying is that I want to distinguish between something that does not affect liveness because we don't care about its value (this we should enqueue) and something that does not affect liveness but should be here (e.g., a bug that produced and invalid live-range).

To be concrete, I think we want to do instead:
assert((!LI->empty() || !MRI.reg_nodbg_empty()) && "Empty and not used live-range?!")