This is an archive of the discontinued LLVM Phabricator instance.

Unbundle KILL bundles in VirtRegRewriter
ClosedPublic

Authored by rampitec on Aug 6 2020, 3:50 PM.

Details

Summary

SplitKit forms invalid COPY subreg bundles without a leading
BUNDLE instruction. That manifests itself in post-RA scheduler
counting instruction and asserting on "Instruction count mismatch".

The bundle shall be undone by VirtRegRewriter::expandCopyBundle(),
but it does not because VirtRegRewriter::handleIdentityCopy() can
turn COPY bundle into a KILL bundle.

Process KILLs as well.

Diff Detail

Event Timeline

rampitec created this revision.Aug 6 2020, 3:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2020, 3:50 PM
rampitec requested review of this revision.Aug 6 2020, 3:50 PM
foad added a subscriber: foad.Aug 7 2020, 2:48 AM
foad added a subscriber: MatzeB.Aug 7 2020, 2:59 AM

SplitKit forms invalid COPY subreg bundles without a leading BUNDLE instruction.

From reading through @MatzeB's D30438, it looks like this was done intentionally and they were all supposed to be unbundled again by VirtRegRewriter::expandCopyBundle, i.e. before the post RA scheduler runs.

lkail added a subscriber: lkail.Aug 7 2020, 8:44 AM

For the context, there is also D85456 which just fixes instruction counting in the scheduler, although consensus was a bundle without BOUNDLE instruction is illegal.

foad added a comment.Aug 7 2020, 10:57 AM

consensus was a bundle without BOUNDLE instruction is illegal.

I don't disagree with that, but I wonder why it isn't working the way D30438 was designed. Is there some reason why expandCopyBundle is not unbundling all the BUNDLE-less bundles?

consensus was a bundle without BOUNDLE instruction is illegal.

I don't disagree with that, but I wonder why it isn't working the way D30438 was designed. Is there some reason why expandCopyBundle is not unbundling all the BUNDLE-less bundles?

I do not think that is a good idea to unbundle just everything. Ideally this code shall only expand what was created by the SplitKit and do not touch what was bundled by an user code for any other reason.
Then do you think forming of an invalid bundle is a good idea to distinguish?
I am now playing with the change which will unboundle COPY and KILL bundles, not just COPY.

rampitec updated this revision to Diff 283967.Aug 7 2020, 11:39 AM
rampitec edited the summary of this revision. (Show Details)

Handle KILLs when unbundling.

There is probably a question do we need to insert BUNDLE header or just unpack KILLs as well? Having a bundle without a header is not legal, but having a header can mess with target code. I believe D30438 did not have a perfect solution.

rampitec updated this revision to Diff 284006.Aug 7 2020, 1:07 PM
rampitec retitled this revision from Properly form bundles in SplitKit to Unbundle KILL bundles in VirtRegRewriter.
rampitec edited the summary of this revision. (Show Details)

After all these changes I now believe these are two separate problems and two separate patches. Handling of KILLs is what solves the problem and what needs to be done anyway. A question of proper formation and marking of transient bundles is a separate issue.

Changed to only handle KILLs. I believe it should make the patch not controversial.

foad added a comment.Aug 7 2020, 2:35 PM

Looks good to me, thanks.

arsenm accepted this revision.Aug 10 2020, 10:45 AM
This revision is now accepted and ready to land.Aug 10 2020, 10:45 AM
This revision was automatically updated to reflect the committed changes.