[PATCH] D25041: Refactor the ProfileSummaryInfo to use doInitialization and doFinalization to handle Module update.
Dehao Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 28 13:36:15 PDT 2016
danielcdh created this revision.
danielcdh added reviewers: davidxl, eraman, mehdi_amini.
danielcdh added a subscriber: llvm-commits.
This refactors the change in r282616
https://reviews.llvm.org/D25041
Files:
include/llvm/Analysis/ProfileSummaryInfo.h
lib/Analysis/ModuleSummaryAnalysis.cpp
lib/Analysis/ProfileSummaryInfo.cpp
lib/Transforms/IPO/Inliner.cpp
Index: lib/Transforms/IPO/Inliner.cpp
===================================================================
--- lib/Transforms/IPO/Inliner.cpp
+++ lib/Transforms/IPO/Inliner.cpp
@@ -634,7 +634,7 @@
bool Inliner::inlineCalls(CallGraphSCC &SCC) {
CallGraph &CG = getAnalysis<CallGraphWrapperPass>().getCallGraph();
ACT = &getAnalysis<AssumptionCacheTracker>();
- PSI = getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI(CG.getModule());
+ PSI = getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
// We compute dedicated AA results for each function in the SCC as needed. We
// use a lambda referencing external objects so that they live long enough to
Index: lib/Analysis/ProfileSummaryInfo.cpp
===================================================================
--- lib/Analysis/ProfileSummaryInfo.cpp
+++ lib/Analysis/ProfileSummaryInfo.cpp
@@ -132,22 +132,24 @@
return ColdCountThreshold && C <= ColdCountThreshold.getValue();
}
-ProfileSummaryInfo *ProfileSummaryInfoWrapperPass::getPSI(Module &M) {
- if (!PSI)
- PSI.reset(new ProfileSummaryInfo(&M));
- else
- PSI->resetModule(&M);
- return PSI.get();
-}
-
INITIALIZE_PASS(ProfileSummaryInfoWrapperPass, "profile-summary-info",
"Profile summary info", false, true)
ProfileSummaryInfoWrapperPass::ProfileSummaryInfoWrapperPass()
: ImmutablePass(ID) {
initializeProfileSummaryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
}
+bool ProfileSummaryInfoWrapperPass::doInitialization(Module &M) {
+ PSI.reset(new ProfileSummaryInfo(&M));
+ return false;
+}
+
+bool ProfileSummaryInfoWrapperPass::doFinalization(Module &M) {
+ PSI.reset();
+ return false;
+}
+
char ProfileSummaryAnalysis::PassID;
ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M,
ModuleAnalysisManager &) {
Index: lib/Analysis/ModuleSummaryAnalysis.cpp
===================================================================
--- lib/Analysis/ModuleSummaryAnalysis.cpp
+++ lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -228,7 +228,7 @@
}
bool ModuleSummaryIndexWrapperPass::runOnModule(Module &M) {
- auto &PSI = *getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI(M);
+ auto &PSI = *getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI();
Index = buildModuleSummaryIndex(
M,
[this](const Function &F) {
Index: include/llvm/Analysis/ProfileSummaryInfo.h
===================================================================
--- include/llvm/Analysis/ProfileSummaryInfo.h
+++ include/llvm/Analysis/ProfileSummaryInfo.h
@@ -71,7 +71,12 @@
static char ID;
ProfileSummaryInfoWrapperPass();
- ProfileSummaryInfo *getPSI(Module &M);
+ ProfileSummaryInfo *getPSI() {
+ return &*PSI;
+ }
+
+ bool doInitialization(Module &M) override;
+ bool doFinalization(Module &M) override;
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25041.72888.patch
Type: text/x-patch
Size: 3009 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160928/1e597a18/attachment.bin>
More information about the llvm-commits
mailing list