This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][NFC] Organize code around reserving VGPR32 for AGPR copy.
ClosedPublic

Authored by hsmhsm on Apr 12 2022, 8:39 PM.

Details

Summary

This is an NFC patch in preparation to fix a bug related to always
reserving VGPR32 for AGPR copy.

Diff Detail

Event Timeline

hsmhsm created this revision.Apr 12 2022, 8:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2022, 8:39 PM
hsmhsm requested review of this revision.Apr 12 2022, 8:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2022, 8:39 PM
cdevadas added inline comments.Apr 12 2022, 11:04 PM
llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h
497

No need for the initializer. It takes NoRegister by default.

llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
702

I don't think it's the right place to reserve the VGPR by changing the constness of MFI.
May be finalizeLowering?

hsmhsm updated this revision to Diff 422430.Apr 13 2022, 1:34 AM

Fix few review comments by CD.

hsmhsm marked 2 inline comments as done.Apr 13 2022, 1:40 AM
hsmhsm added inline comments.
llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
702

Actually, it may not work in case of mir lit tests which may not call finalizeLowering(), but may call getReservedRegs().

Nevertheless it is not a good idea to remove constness and mutate const object. For now, since it an NFC patch, and which actually just refactor the code around reserving VGPR for AGPR copy, let me not add code to mutate const object.

And, in the next subsequent patch, let me think if we can handle it better.

hsmhsm marked an inline comment as done.Apr 13 2022, 1:41 AM
hsmhsm updated this revision to Diff 422451.Apr 13 2022, 3:08 AM

Minor update to member initialization.

rampitec added inline comments.Apr 13 2022, 1:15 PM
llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
1560

There is already assert inside getVGPRForAGPRCopy.

hsmhsm marked an inline comment as done.Apr 13 2022, 6:30 PM
hsmhsm added inline comments.
llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
1560

The assert inside getVGPRForAGPRCopy() is to assert that some valid VGPR (only in case of gfx908) is identified, which may or may not yet reserved (by calling getReservedRegs()).

On the other hand, the assert here assert that the identified valid VGPR is also reserved.

hsmhsm updated this revision to Diff 422728.Apr 13 2022, 8:06 PM
hsmhsm marked an inline comment as done.

Fix assert message.

rampitec accepted this revision.Apr 14 2022, 12:17 AM
This revision is now accepted and ready to land.Apr 14 2022, 12:17 AM
This revision was landed with ongoing or failed builds.Apr 14 2022, 12:22 AM
This revision was automatically updated to reflect the committed changes.