This is an archive of the discontinued LLVM Phabricator instance.

[RegisterCoalescer] Fix for assert in removePartialRedundancy
ClosedPublic

Authored by tpr on Aug 17 2018, 11:50 AM.

Details

Summary

I got "Use not jointly dominated by defs" when removePartialRedundancy
attempted to prune then re-extend a subrange whose only liveness was a
dead def at the copy being removed.

Change-Id: I6f894e9f517f71e921e0c6d81d28c5f344db8dad

Diff Detail

Event Timeline

tpr created this revision.Aug 17 2018, 11:50 AM
tpr added a subscriber: dstuttard.
MatzeB added a reviewer: wmi.Aug 20 2018, 8:56 AM

It would help review if you could describe the exact situation this happens. I am wondering:

  • Why isn't this fix necessary in the main liverange?
  • Is the fix only necessary for removePartialRedundancy() or should be pruneValue() or extendToIndices() so it applies to all similar situations?

Please read https://llvm.org/docs/MIRLangRef.html#simplifying-mir-files

Generally we should have a short test that just exposes the problem (such short tests also often intuitively demonstrate the problem that is fixed) rather than hundreds of lines of dumped IR.

tpr updated this revision to Diff 161988.Aug 22 2018, 10:20 AM

V2: Removed junk from test; improved comment.

tpr added a comment.Aug 22 2018, 10:30 AM

Hi Matthias

Thanks for the pointer on MIR tests. I stripped out all the unnecessary IR, but I left the MIR as it was because that was already the result of bugpointing the original test case.

Is that comment better for understanding the situation in which it happens?

Why isn't this fix necessary in the main liverange?

The main liverange would never be immediately dead at the copy because the dead copy would have been removed before getting to removePartialRedundancy, right?

Is the fix only necessary for removePartialRedundancy() or should be pruneValue() or extendToIndices() so it applies to all similar situations?

I don't know the answer to that. But note that it is only valid to remove the endpoint at the same index as the copy because we know it must come from a dead def, rather than a normal use at the same place. We know that because the copy is a full copy. That same thing might not apply in other cases of pruneValue()/extendToIndices().

MatzeB accepted this revision.Aug 22 2018, 10:47 AM

LGTM with nitpicks addressed.

lib/CodeGen/RegisterCoalescer.cpp
1141

Using SlotIndex::isSameInstr() would make the intention more clear.

test/CodeGen/AMDGPU/regcoalescing-remove-partial-redundancy-assert.mir
11–14

Could you try if the test still works with the registers: block removed? It seems the machine operands below have the register classes annotated anyway.

This revision is now accepted and ready to land.Aug 22 2018, 10:47 AM
tpr marked an inline comment as done.Aug 23 2018, 9:11 AM
tpr added inline comments.
test/CodeGen/AMDGPU/regcoalescing-remove-partial-redundancy-assert.mir
11–14

Yes, it does work without the registers: block. I will remove it.

tpr updated this revision to Diff 162197.Aug 23 2018, 9:13 AM
tpr marked an inline comment as done.

V3: Addressed minor review comments.
No need to re-approve.

This revision was automatically updated to reflect the committed changes.