This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Fix assertion failure in TwoAddressInstructionPass::rescheduleMIBelowKill
ClosedPublic

Authored by foad on Nov 3 2021, 8:47 AM.

Details

Summary

This fixes an assertion failure with -early-live-intervals when trying
to update the live intervals for a dbug instruction, which don't even
have slot indexes.

Diff Detail

Event Timeline

foad created this revision.Nov 3 2021, 8:47 AM
foad requested review of this revision.Nov 3 2021, 8:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 3 2021, 8:47 AM

Any other comments?

llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
958–959

Adjust this - since we're not actually moving the debug instr copies

foad added inline comments.Nov 8 2021, 1:47 AM
llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
958–959

Not quite sure what you mean. The instructions in the range [AfterMI,End) are a mixture of copies and debug instructions. We are moving all of them, but (with this patch) only updating LiveIntervals when we move a copy. I think the comment above is still accurate. Did you have a suggestion for improving it?

MatzeB added a comment.Nov 8 2021, 8:44 AM

Let's fix the condition then this is good to go.

llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
958–959

I also needed a while to understand this comment, since it implies that there are only COPY instructions here. I think you should either tweak the comment to say that there may be debug or pseudo instructions mixed in or add a comment before the if (isDebugOrPseudoInstr().

963–964

The condition used in SlotIndexes.cpp and in skipDebugInstructionsForward (I wish it had a better name) seems to be isDebugOrPseudoInstr().

You could go for LiveIntervals::hasIndex() instead to be safe for future changes (at the cost of an extra map lookup). I'll let you make the call depending on how perf critical you judge this part.

foad updated this revision to Diff 385572.Nov 8 2021, 10:54 AM

Use isDebugOrPseudoInstr. Update comment.

MatzeB accepted this revision.Nov 8 2021, 11:26 AM

LGTM

This revision is now accepted and ready to land.Nov 8 2021, 11:26 AM