[clang] [llvm] [AMDGPU] Convert AMDGPUResourceUsageAnalysis pass from Module to MF pass (PR #102913)
Janek van Oirschot via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 21 05:48:52 PDT 2024
================
@@ -68,82 +71,84 @@ void MCResourceInfo::assignMaxRegs() {
assignMaxRegSym(MaxSGPRSym, MaxSGPR);
}
-void MCResourceInfo::finalize() {
- assert(!finalized && "Cannot finalize ResourceInfo again.");
- finalized = true;
- assignMaxRegs();
+void MCResourceInfo::finalize(MCContext &OutContext) {
+ assert(!Finalized && "Cannot finalize ResourceInfo again.");
+ Finalized = true;
+ assignMaxRegs(OutContext);
}
-MCSymbol *MCResourceInfo::getMaxVGPRSymbol() {
+MCSymbol *MCResourceInfo::getMaxVGPRSymbol(MCContext &OutContext) {
return OutContext.getOrCreateSymbol("max_num_vgpr");
}
-MCSymbol *MCResourceInfo::getMaxAGPRSymbol() {
+MCSymbol *MCResourceInfo::getMaxAGPRSymbol(MCContext &OutContext) {
return OutContext.getOrCreateSymbol("max_num_agpr");
}
-MCSymbol *MCResourceInfo::getMaxSGPRSymbol() {
+MCSymbol *MCResourceInfo::getMaxSGPRSymbol(MCContext &OutContext) {
return OutContext.getOrCreateSymbol("max_num_sgpr");
}
void MCResourceInfo::assignResourceInfoExpr(
- int64_t localValue, ResourceInfoKind RIK, AMDGPUMCExpr::VariantKind Kind,
- const MachineFunction &MF,
- const SmallVectorImpl<const Function *> &Callees) {
- const MCConstantExpr *localConstExpr =
- MCConstantExpr::create(localValue, OutContext);
- const MCExpr *SymVal = localConstExpr;
+ int64_t LocalValue, ResourceInfoKind RIK, AMDGPUMCExpr::VariantKind Kind,
+ const MachineFunction &MF, const SmallVectorImpl<const Function *> &Callees,
+ MCContext &OutContext) {
+ const MCConstantExpr *LocalConstExpr =
+ MCConstantExpr::create(LocalValue, OutContext);
+ const MCExpr *SymVal = LocalConstExpr;
----------------
JanekvO wrote:
Had to look into this a bit as I wasn't aware of the !callees metadata: but yes, we currently don't take advantage of this. I was able to create an example that emits the !callees metadata for an indirect call but it will always fall back on the worst case (i.e., module level worst case values).
https://github.com/llvm/llvm-project/pull/102913
More information about the cfe-commits
mailing list