This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GISel] Fix selection of G_CONSTANT_FOLD_BARRIER
ClosedPublic

Authored by dmgreen on Aug 6 2023, 12:07 AM.

Details

Summary

As far as I understand - When lowering a G_CONSTANT_FOLD_BARRIER we replace the DstReg with SrcReg, and need to check that the register class is equivalent when doing so for the replacement to be legal. During lowering we could end up visiting nodes in an odd order, leaving a G_CONSTANT_FOLD_BARRIER with a known regclass for the src, but only a regbank for the dst. Providing the Regbank contains the regclass, the replacement should still be safe.

This fixes an assert seen in the llvm-test-suite when lowering hoisted constants, relaxing the assert to account for the difference in visiting order.

Diff Detail

Unit TestsFailed

Event Timeline

dmgreen created this revision.Aug 6 2023, 12:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2023, 12:07 AM
dmgreen requested review of this revision.Aug 6 2023, 12:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2023, 12:07 AM
Herald added a subscriber: wdng. · View Herald Transcript
tschuett added inline comments.
llvm/test/CodeGen/AArch64/GlobalISel/select-constbarrier.mir
161

The verifier allows unconditional branches after conditional branches?

tschuett added inline comments.Aug 6 2023, 1:28 AM
llvm/test/CodeGen/AArch64/GlobalISel/select-constbarrier.mir
161

Deleted!!!

arsenm added inline comments.Aug 9 2023, 1:36 PM
llvm/test/CodeGen/AArch64/GlobalISel/select-constbarrier.mir
5

Should drop IR section

190–198

This can be reduced, can try llvm-reduce mir handling

dmgreen updated this revision to Diff 548914.Aug 10 2023, 1:21 AM

Reduce test size.

arsenm added inline comments.Aug 11 2023, 12:12 PM
llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
182–185

I would assume canReplaceReg covers all this

dmgreen updated this revision to Diff 549809.Aug 14 2023, 12:53 AM

Move the logic into canReplaceReg.

aemerson accepted this revision.Aug 15 2023, 1:30 PM
This revision is now accepted and ready to land.Aug 15 2023, 1:30 PM
This revision was automatically updated to reflect the committed changes.