This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Move machine bundle unpacking to PreEmit2 phase.
ClosedPublic

Authored by fhahn on Feb 8 2021, 2:25 PM.

Details

Summary

This patch adjusts the placement of the bundle unpacking to just before
code emission. In particular, this means bundle unpacking happens AFTER
the machine outliner. With the previous position, the machine outliner
may outline parts of a bundle, which breaks them up.

This is an issue for BLR_RVMARKER handling, as illustrated by the
rvmarker-pseudo-expansion-and-outlining.mir test case. The machine
outliner should not break up the bundles created during pseudo
expansion.

This should fix PR49082.

Diff Detail

Event Timeline

fhahn created this revision.Feb 8 2021, 2:25 PM
fhahn requested review of this revision.Feb 8 2021, 2:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2021, 2:25 PM
kyulee added a subscriber: kyulee.Feb 8 2021, 4:03 PM

This minor reshuffle looks very reasonable to me, but I was wondering about this:

With the previous position, the machine outliner may outline parts of a bundle, which breaks them up.

I am not that familiar with the instruction bundles, and the MIR langref description is a bit minimal, but was curious and wanted to ask if this is what the outliner should be doing, i.e. breaking up bundles?

llvm/test/CodeGen/AArch64/rvmarker-pseudo-expansion-and-outlining.mir
21

Nit: outline -> outlined, and > 80 columns?

79

Same

fhahn updated this revision to Diff 323342.Feb 12 2021, 8:30 AM

This minor reshuffle looks very reasonable to me, but I was wondering about this:

With the previous position, the machine outliner may outline parts of a bundle, which breaks them up.

I am not that familiar with the instruction bundles, and the MIR langref description is a bit minimal, but was curious and wanted to ask if this is what the outliner should be doing, i.e. breaking up bundles?

Machine instruction bundles are sequences of instructions that should be kept together back-to-back. The problem is that the bundle expansion (which gets rid of the bundles) runs before the machine outliner, so the bundles are gone when the outliner runs and it can outline parts of the instructions in the bundle.

The only uses of bundles in the AArch64 backend is to keep SVE MOVPRFX instructions together with a 2nd instruction and the BLR_RVMARKER handling, which should expand to a call, followed by mov x29, x29. In both cases, the outliner should not outline only parts of the sequence.

I think in the MOVPRFX cases, it would be a mis-compile if the MOVPRRX instruction gets moved. And moving the marker instruction mov x29, x29 prevents runtime optimizations. So I think for both use cases, running bundle expansion late is the right thing to do.

I updated the test to more directly check for that behavior. Without the patch, mov x29, x29 (which gets added during BLR_RVMARKER expansion) gets outlined, which is not desirable.

fhahn updated this revision to Diff 323343.Feb 12 2021, 8:31 AM

Drop fixme from test

fhahn added inline comments.Feb 12 2021, 8:33 AM
llvm/test/CodeGen/AArch64/rvmarker-pseudo-expansion-and-outlining.mir
21

Drastically reworked the test, so the comment is gone :)

SjoerdMeijer accepted this revision.Feb 15 2021, 2:48 AM

Thanks, that's clear and LGTM.

This revision is now accepted and ready to land.Feb 15 2021, 2:48 AM
This revision was automatically updated to reflect the committed changes.