diff options
author | Vitaly Buka <vitalybuka@google.com> | 2020-08-07 13:58:10 -0700 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2020-08-07 14:02:50 -0700 |
commit | 7d4996033bc57c5fa4153a0191ed48f4d287f48c (patch) | |
tree | d90db9931e58265ab82479a6fe2bed6f080cd6f4 /llvm/lib/Analysis/StackSafetyAnalysis.cpp | |
parent | 660832c4e744108ecb45b697e51be72482cacd42 (diff) | |
download | llvm-7d4996033bc57c5fa4153a0191ed48f4d287f48c.zip llvm-7d4996033bc57c5fa4153a0191ed48f4d287f48c.tar.gz llvm-7d4996033bc57c5fa4153a0191ed48f4d287f48c.tar.bz2 |
[StackSafety,NFC] Add Stats counters
Diffstat (limited to 'llvm/lib/Analysis/StackSafetyAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/StackSafetyAnalysis.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp b/llvm/lib/Analysis/StackSafetyAnalysis.cpp index 042062a..0e2c446 100644 --- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp +++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp @@ -45,6 +45,10 @@ STATISTIC(NumModuleCalleeLookupTotal, "Number of total callee lookups on module index."); STATISTIC(NumModuleCalleeLookupFailed, "Number of failed callee lookups on module index."); +STATISTIC(NumCombinedParamAccessesBefore, + "Number of total param accesses before generateParamAccessSummary."); +STATISTIC(NumCombinedParamAccessesAfter, + "Number of total param accesses after generateParamAccessSummary."); static cl::opt<int> StackSafetyMaxIterations("stack-safety-max-iterations", cl::init(20), cl::Hidden); @@ -936,6 +940,18 @@ void llvm::generateParamAccessSummary(ModuleSummaryIndex &Index) { if (!Index.hasParamAccess()) return; const ConstantRange FullSet(FunctionSummary::ParamAccess::RangeWidth, true); + + auto CountParamAccesses = [&](StatisticBase &Counter) { + if (!AreStatisticsEnabled()) + return; + for (auto &GVS : Index) + for (auto &GV : GVS.second.SummaryList) + if (FunctionSummary *FS = dyn_cast<FunctionSummary>(GV.get())) + NumCombinedParamAccessesAfter += FS->paramAccesses().size(); + }; + + CountParamAccesses(NumCombinedParamAccessesBefore); + std::map<const FunctionSummary *, FunctionInfo<FunctionSummary>> Functions; // Convert the ModuleSummaryIndex to a FunctionMap @@ -988,6 +1004,8 @@ void llvm::generateParamAccessSummary(ModuleSummaryIndex &Index) { const_cast<FunctionSummary *>(KV.first)->setParamAccesses( std::move(NewParams)); } + + CountParamAccesses(NumCombinedParamAccessesAfter); } static const char LocalPassArg[] = "stack-safety-local"; |