Skip to content

Commit 7d49960

Browse files
committed
[StackSafety,NFC] Add Stats counters
1 parent 660832c commit 7d49960

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

llvm/lib/Analysis/StackSafetyAnalysis.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ STATISTIC(NumModuleCalleeLookupTotal,
4545
"Number of total callee lookups on module index.");
4646
STATISTIC(NumModuleCalleeLookupFailed,
4747
"Number of failed callee lookups on module index.");
48+
STATISTIC(NumCombinedParamAccessesBefore,
49+
"Number of total param accesses before generateParamAccessSummary.");
50+
STATISTIC(NumCombinedParamAccessesAfter,
51+
"Number of total param accesses after generateParamAccessSummary.");
4852

4953
static cl::opt<int> StackSafetyMaxIterations("stack-safety-max-iterations",
5054
cl::init(20), cl::Hidden);
@@ -936,6 +940,18 @@ void llvm::generateParamAccessSummary(ModuleSummaryIndex &Index) {
936940
if (!Index.hasParamAccess())
937941
return;
938942
const ConstantRange FullSet(FunctionSummary::ParamAccess::RangeWidth, true);
943+
944+
auto CountParamAccesses = [&](StatisticBase &Counter) {
945+
if (!AreStatisticsEnabled())
946+
return;
947+
for (auto &GVS : Index)
948+
for (auto &GV : GVS.second.SummaryList)
949+
if (FunctionSummary *FS = dyn_cast<FunctionSummary>(GV.get()))
950+
NumCombinedParamAccessesAfter += FS->paramAccesses().size();
951+
};
952+
953+
CountParamAccesses(NumCombinedParamAccessesBefore);
954+
939955
std::map<const FunctionSummary *, FunctionInfo<FunctionSummary>> Functions;
940956

941957
// Convert the ModuleSummaryIndex to a FunctionMap
@@ -988,6 +1004,8 @@ void llvm::generateParamAccessSummary(ModuleSummaryIndex &Index) {
9881004
const_cast<FunctionSummary *>(KV.first)->setParamAccesses(
9891005
std::move(NewParams));
9901006
}
1007+
1008+
CountParamAccesses(NumCombinedParamAccessesAfter);
9911009
}
9921010

9931011
static const char LocalPassArg[] = "stack-safety-local";

0 commit comments

Comments
 (0)