MachineBasicBlock asserts in erase() and move()

Hi,

It has been discovered that SystemZTargetLowering::emitSelect() calls erase() on a range of instructions on the wrong MBB, without any assert triggering with seemingly correct behaviour (!). StartMBB->erase() should be JoinMBB->erase() since that's where the SelectPseudo(s) will reside.

I am not sure why this "works" at the moment, or why there is not an assert checking for this. I made a patch to add asserts in erase() and remove() methods (attached), but found no other cases, though.

Is there a reason this is not asserted in ilist?

/Jonas

latest.patch (2.3 KB)

Probably works because a linked list doesn’t necessarily need to consult the list object itself when doing operations on subranges of it - it can manipulate the nodes directly so it doesn’t tend to matter what list those nodes belong to.

& if it doesn’t fail, inevitably someone’ll accidentally rely on it.

An assert wouldn’t be a bad thing, I think.