aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorJuan Manuel MARTINEZ CAAMAÑO <juamarti@amd.com>2023-06-29 09:11:54 +0200
committerJuan Manuel MARTINEZ CAAMAÑO <juamarti@amd.com>2023-06-29 09:49:16 +0200
commitcc8a346e3fa362c2b1319cca9883182fbf36b6db (patch)
tree72a3305063c83b800e25e3125ee8cd82d68c5c60 /llvm/lib/Analysis/InlineCost.cpp
parent9e37142dc12a7d57a793db56ea5fd259171fe20a (diff)
downloadllvm-cc8a346e3fa362c2b1319cca9883182fbf36b6db.zip
llvm-cc8a346e3fa362c2b1319cca9883182fbf36b6db.tar.gz
llvm-cc8a346e3fa362c2b1319cca9883182fbf36b6db.tar.bz2
[InlineCost][TargetTransformInfo][AMDGPU] Consider cost of alloca instructions in the caller (1/2)
On AMDGPU, alloca instructions have penalty that can be avoided when SROA is applied after inlining. This patch introduces the default implementation of TargetTransformInfo::getCallerAllocaCost. Reviewed By: mtrofin Differential Revision: https://reviews.llvm.org/D149740
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index d887adc..9ff277f 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -717,7 +717,9 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
void onInitializeSROAArg(AllocaInst *Arg) override {
assert(Arg != nullptr &&
"Should not initialize SROA costs for null value.");
- SROAArgCosts[Arg] = 0;
+ auto SROAArgCost = TTI.getCallerAllocaCost(&CandidateCall, Arg);
+ SROACostSavings += SROAArgCost;
+ SROAArgCosts[Arg] = SROAArgCost;
}
void onAggregateSROAUse(AllocaInst *SROAArg) override {
@@ -1191,7 +1193,12 @@ private:
InstrCost);
}
- void onInitializeSROAArg(AllocaInst *Arg) override { SROACosts[Arg] = 0; }
+ void onInitializeSROAArg(AllocaInst *Arg) override {
+ auto SROAArgCost = TTI.getCallerAllocaCost(&CandidateCall, Arg);
+ SROACosts[Arg] = SROAArgCost;
+ SROACostSavingOpportunities += SROAArgCost;
+ }
+
void onAggregateSROAUse(AllocaInst *Arg) override {
SROACosts.find(Arg)->second += InstrCost;
SROACostSavingOpportunities += InstrCost;