This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][IndirectCalls] Fix register usage propagation for indirect/external calls
ClosedPublic

Authored by madhur13490 on Jun 3 2021, 10:52 AM.

Details

Summary

This patch computes max SGPRs and VGPRs used by module
in presence of indirect calls and makes that
as register requirement for functions/kernels
which makes indirect calls.

This patch also refactors code AMDGPUSubTarget.cpp
which add a "base" variants of getMaxNumSGPRs which
is used by MachineFunction and new Function version.

Diff Detail

Event Timeline

madhur13490 created this revision.Jun 3 2021, 10:52 AM
madhur13490 requested review of this revision.Jun 3 2021, 10:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 3 2021, 10:52 AM
madhur13490 added inline comments.Jun 3 2021, 10:56 AM
llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
728

This condition is too big. Are some checks redundant?

sebastian-ne added inline comments.
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
106

This is actually the max SGPR usage for *all non-entrypoint functions* in the module, not for the whole module.

arsenm added inline comments.Jun 8 2021, 11:43 AM
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
633

Add a comment?

1047

I think for accounting purposes it would be nicer to not include these in the function totals to begin with, but I guess it doesn't really matter

llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
726–727

I don't like relying on these attributes. Can you just assume they are true?

address review comments + rebase

madhur13490 marked 2 inline comments as done.Jun 9 2021, 2:40 AM
madhur13490 added inline comments.
llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
726–727

But that will deviate from the current behavior.

arsenm accepted this revision.Jun 11 2021, 7:51 AM
arsenm added inline comments.
llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
726–727

OK, as a followup change, can you just make these assume true?

This revision is now accepted and ready to land.Jun 11 2021, 7:51 AM
This revision was landed with ongoing or failed builds.Jun 11 2021, 11:29 PM
This revision was automatically updated to reflect the committed changes.
madhur13490 added inline comments.Jun 11 2021, 11:30 PM
llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
726–727

Sure, will try if PSDB passes.