AMDGPU: Use module level register maximums for unknown callees
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 14 Jan 2022 01:13:29 +0000 (20:13 -0500)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 4 Feb 2022 20:56:03 +0000 (15:56 -0500)
commit935abab65cafb509f60e76bd7255dfe03befde85
treef7bbad20bab5e01e288f2550d6c2b7c23e66b836
parent679f8a885b65e0c82537590f1d88c2bc4c6869bc
AMDGPU: Use module level register maximums for unknown callees

Compute the theoretical register budget based on the IR function
signature/attributes, and use the global maximum register budgets for
unknown callees.

This should fix the kernel reported register usage in the presence of
indirect calls. The previous fix in
2b08f6af62afbf32e89a6a392dbafa92c62f7bdf was incorrect becauset it was
only taking the maximum in the known call graph, and missing something
that was either outside of it or codegened later.

This fixes a second case I discovered where calls to aliases also did
not work as expected. CallGraphAnalysis misses these, so functions
called through aliases were not codegened ahead of callers as
expected. CallGraphAnalysis should probably be fixed to understand
this case, and there's likely a bug with IPRA here. This fixes
numerous failures in the conformance test at -O0.
13 files changed:
llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.h
llvm/lib/Target/AMDGPU/GCNSubtarget.h
llvm/test/CodeGen/AMDGPU/agpr-register-count.ll
llvm/test/CodeGen/AMDGPU/amdpal-callable.ll
llvm/test/CodeGen/AMDGPU/attr-amdgpu-flat-work-group-size-vgpr-limit.ll
llvm/test/CodeGen/AMDGPU/call-alias-register-usage-agpr.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/call-alias-register-usage0.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/call-alias-register-usage1.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/call-alias-register-usage2.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/call-alias-register-usage3.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/call-graph-register-usage.ll
llvm/test/CodeGen/AMDGPU/indirect-call.ll