diff options
author | Teresa Johnson <tejohnson@google.com> | 2018-11-17 20:03:22 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2018-11-17 20:03:22 +0000 |
commit | 8c1915cc0196a093145970b185e6cc4882de8d7a (patch) | |
tree | da3853fc1e955d458a0ffaa17e29c1aaba28509b /llvm/lib/IR/ModuleSummaryIndex.cpp | |
parent | f4bf671af75854f2459ad6ac2b0551efb6811b88 (diff) | |
download | bcm5719-llvm-8c1915cc0196a093145970b185e6cc4882de8d7a.tar.gz bcm5719-llvm-8c1915cc0196a093145970b185e6cc4882de8d7a.zip |
[ThinLTO] Add some stats for read only variable internalization
Summary:
Follow up to D49362 ([ThinLTO] Internalize read only globals). Add a
statistic on the number of read only variables (only counting live
variables since dead variables will be dropped anyway).
Reviewers: evgeny777
Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, arphaman, llvm-commits
Differential Revision: https://reviews.llvm.org/D54642
llvm-svn: 347145
Diffstat (limited to 'llvm/lib/IR/ModuleSummaryIndex.cpp')
-rw-r--r-- | llvm/lib/IR/ModuleSummaryIndex.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/IR/ModuleSummaryIndex.cpp b/llvm/lib/IR/ModuleSummaryIndex.cpp index 6c0d3973715..bb5b7d0d3ab 100644 --- a/llvm/lib/IR/ModuleSummaryIndex.cpp +++ b/llvm/lib/IR/ModuleSummaryIndex.cpp @@ -14,11 +14,17 @@ #include "llvm/IR/ModuleSummaryIndex.h" #include "llvm/ADT/SCCIterator.h" +#include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; +#define DEBUG_TYPE "module-summary-index" + +STATISTIC(ReadOnlyLiveGVars, + "Number of live global variables marked read only"); + FunctionSummary FunctionSummary::ExternalNode = FunctionSummary::makeDummyFunctionSummary({}); bool ValueInfo::isDSOLocal() const { @@ -160,6 +166,14 @@ void ModuleSummaryIndex::propagateConstants( GVS->setReadOnly(false); propagateConstantsToRefs(S.get()); } +#if LLVM_ENABLE_STATS + for (auto &P : *this) + if (P.second.SummaryList.size()) + if (auto *GVS = dyn_cast<GlobalVarSummary>( + P.second.SummaryList[0]->getBaseObject())) + if (isGlobalValueLive(GVS) && GVS->isReadOnly()) + ReadOnlyLiveGVars++; +#endif } // TODO: write a graphviz dumper for SCCs (see ModuleSummaryIndex::exportToDot) |