[llvm] [AMDGPU] Do not propagate vgpr count in dVGPR mode (PR #187078)
Mirko BrkuĊĦanin via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 31 05:46:22 PDT 2026
================
@@ -298,9 +299,37 @@ void MCResourceInfo::gatherResourceInfo(
}
};
+ auto SetToLocal = [&](int64_t LocalValue, ResourceInfoKind RIK) {
+ MCSymbol *Sym = getSymbol(FnSym->getName(), RIK, OutContext, IsLocal);
+ LLVM_DEBUG(
+ dbgs() << "MCResUse: " << Sym->getName() << ": Adding " << LocalValue
+ << ", no further propagation as indirect callee found within\n");
+ Sym->setVariableValue(MCConstantExpr::create(LocalValue, OutContext));
+ };
+
LLVM_DEBUG(dbgs() << "MCResUse: " << FnSym->getName() << '\n');
- SetMaxReg(MaxVGPRSym, FRI.NumVGPR, RIK_NumVGPR);
- SetMaxReg(MaxAGPRSym, FRI.NumAGPR, RIK_NumAGPR);
+
+ CallingConv::ID CC = MF.getFunction().getCallingConv();
+
+ // When DynamicVGPR is enabled, chain functions should not propagate VGPR
+ // counts from other chain callees since each chain function can have its own
+ // VGPR allocation, but should still propagate from non-chain callees.
+ if (MF.getInfo<SIMachineFunctionInfo>()->isDynamicVGPREnabled() &&
+ (CC == CallingConv::AMDGPU_CS_Chain || CC == CallingConv::AMDGPU_CS)) {
+ SmallVector<const Function *, 16> NonChainCallees;
+ for (const Function *Callee : FRI.Callees) {
+ if (!AMDGPU::isChainCC(Callee->getCallingConv()) &&
+ !Callee->isDeclaration())
+ NonChainCallees.push_back(Callee);
+ }
----------------
mbrkusanin wrote:
Issue is that the way chain functions are set up they will always have `has_indirect_call`.
Conservatively we should be okay with setting the `num_vgpr` for current function as max of current and of all other non-chain functions, if there is a non-chain indirect call. Otherwise use max of all callees as it currently is.
https://github.com/llvm/llvm-project/pull/187078
More information about the llvm-commits
mailing list