This is an archive of the discontinued LLVM Phabricator instance.

Fix instruction counting in post-RA scheduler
AbandonedPublic

Authored by rampitec on Aug 6 2020, 11:15 AM.

Details

Summary

That is possible to bundle instructions but have no leading
BUNDLE. In such a case post-RA scheduler miscalculates a number
of instructions and asserts. The bundle in the test was created
by the Greedy.

Diff Detail

Event Timeline

rampitec created this revision.Aug 6 2020, 11:15 AM
rampitec requested review of this revision.Aug 6 2020, 11:15 AM

Is this really a well formed bundle? i.e. is this really a verifier bug?

Is this really a well formed bundle? i.e. is this really a verifier bug?

That's a good question. Technically that is possible to create such IR. It might be OK post-RA?
For the context, it was created by the SplitEditor::buildSingleSubRegCopy() in the D30438.

arsenm added a comment.Aug 6 2020, 1:13 PM

I think this is an invalid bundle.

Is this really a well formed bundle? i.e. is this really a verifier bug?

That's a good question. Technically that is possible to create such IR. It might be OK post-RA?
For the context, it was created by the SplitEditor::buildSingleSubRegCopy() in the D30438.

I'm inclined to think it's invalid. It looks like using bundles at all was a hack. I think VirtRegRewriter::expandCopyBundle just missed the case where a copy becomes a kill.

Can you add a second test where this weird kill bundle thing is produced?

rampitec updated this revision to Diff 283728.Aug 6 2020, 1:47 PM

Added test resulting in KILL bundle.

I think this is an invalid bundle.

Is this really a well formed bundle? i.e. is this really a verifier bug?

That's a good question. Technically that is possible to create such IR. It might be OK post-RA?
For the context, it was created by the SplitEditor::buildSingleSubRegCopy() in the D30438.

I'm inclined to think it's invalid. It looks like using bundles at all was a hack. I think VirtRegRewriter::expandCopyBundle just missed the case where a copy becomes a kill.

Can you add a second test where this weird kill bundle thing is produced?

Added splitkit-copy-bundle.mir. It produces a bundle with KILLs.

What's interesting I have created a patch to properly bundle copies in the SplitKit, which has resulted in KILLs surviving until inst printer and crash.

Seems wrong to have a bundle without BUNDLE opcode but the change seems fine obviously. Since it's allowed we should probably just account for the possibility.

arsenm added a comment.Aug 6 2020, 2:14 PM

Seems wrong to have a bundle without BUNDLE opcode but the change seems fine obviously. Since it's allowed we should probably just account for the possibility.

But is it? I think this is a failing of the verifier and it is not allowed

Seems wrong to have a bundle without BUNDLE opcode but the change seems fine obviously. Since it's allowed we should probably just account for the possibility.

But is it? I think this is a failing of the verifier and it is not allowed

It probably isn't. But there seems to be quite a few places which do not work with properly formed bundles. One of them is ExpandPostRA.

Seems wrong to have a bundle without BUNDLE opcode but the change seems fine obviously. Since it's allowed we should probably just account for the possibility.

But is it? I think this is a failing of the verifier and it is not allowed

It probably isn't. But there seems to be quite a few places which do not work with properly formed bundles. One of them is ExpandPostRA.

As weird as it sounds VirtRegRewriter::expandCopyBundle() does not work with properly formed bundles as well...

Here is the alternative: D85484. It properly forms bundles in the SplitKit.

foad added a subscriber: foad.Aug 7 2020, 2:48 AM
rampitec abandoned this revision.Aug 7 2020, 1:11 PM

Abandon in favor of D85484.