summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ProfileSummaryInfo.cpp
diff options
context:
space:
mode:
authorDehao Chen <dehao@google.com>2016-09-28 18:41:14 +0000
committerDehao Chen <dehao@google.com>2016-09-28 18:41:14 +0000
commit80c8ebb4d82ed6ee64ae77c2c49085d5b153d8f4 (patch)
treef34b864eeb8566398de9e0c020fdabdebf4a2a5a /llvm/lib/Analysis/ProfileSummaryInfo.cpp
parent42cdfbcf3e92466754c175cb0e1e237e9f66749e (diff)
downloadbcm5719-llvm-80c8ebb4d82ed6ee64ae77c2c49085d5b153d8f4.tar.gz
bcm5719-llvm-80c8ebb4d82ed6ee64ae77c2c49085d5b153d8f4.zip
Fix the bug when -compile-twice is specified, the PSI will be invalidated.
Summary: When using llc with -compile-twice, module is generated twice, but getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI will still get the old PSI with the original (invalidated) Module. This patch checks if the module has changed when calling getPSI, if yes, update the module and invalidate the Summary. The bug does not show up in the current llc because PSI is not used in CodeGen yet. But with https://reviews.llvm.org/D24989, the bug will be exposed by test/CodeGen/PowerPC/pr26378.ll Reviewers: eraman, davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24993 llvm-svn: 282616
Diffstat (limited to 'llvm/lib/Analysis/ProfileSummaryInfo.cpp')
-rw-r--r--llvm/lib/Analysis/ProfileSummaryInfo.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp
index 300b26552d3..ecfa5c2a3fc 100644
--- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp
+++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp
@@ -57,7 +57,7 @@ static uint64_t getMinCountForPercentile(SummaryEntryVector &DS,
void ProfileSummaryInfo::computeSummary() {
if (Summary)
return;
- auto *SummaryMD = M.getProfileSummary();
+ auto *SummaryMD = M->getProfileSummary();
if (!SummaryMD)
return;
Summary.reset(ProfileSummary::getFromMD(SummaryMD));
@@ -113,6 +113,13 @@ void ProfileSummaryInfo::computeThresholds() {
getMinCountForPercentile(DetailedSummary, ProfileSummaryCutoffCold);
}
+void ProfileSummaryInfo::resetModule(Module *NewM) {
+ if (NewM == M)
+ return;
+ M = NewM;
+ Summary.reset(nullptr);
+}
+
bool ProfileSummaryInfo::isHotCount(uint64_t C) {
if (!HotCountThreshold)
computeThresholds();
@@ -127,7 +134,9 @@ bool ProfileSummaryInfo::isColdCount(uint64_t C) {
ProfileSummaryInfo *ProfileSummaryInfoWrapperPass::getPSI(Module &M) {
if (!PSI)
- PSI.reset(new ProfileSummaryInfo(M));
+ PSI.reset(new ProfileSummaryInfo(&M));
+ else
+ PSI->resetModule(&M);
return PSI.get();
}
@@ -142,7 +151,7 @@ ProfileSummaryInfoWrapperPass::ProfileSummaryInfoWrapperPass()
char ProfileSummaryAnalysis::PassID;
ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M,
ModuleAnalysisManager &) {
- return ProfileSummaryInfo(M);
+ return ProfileSummaryInfo(&M);
}
// FIXME: This only tests isHotFunction and isColdFunction and not the
OpenPOWER on IntegriCloud