[PATCH] D24993: Fix the bug when -compile-twice is specified, the PSI will be invalidated.
Dehao Chen via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 27 17:41:24 PDT 2016
danielcdh updated this revision to Diff 72744.
danielcdh added a comment.
update
https://reviews.llvm.org/D24993
Files:
include/llvm/Analysis/ProfileSummaryInfo.h
lib/Analysis/ProfileSummaryInfo.cpp
Index: lib/Analysis/ProfileSummaryInfo.cpp
===================================================================
--- lib/Analysis/ProfileSummaryInfo.cpp
+++ lib/Analysis/ProfileSummaryInfo.cpp
@@ -57,7 +57,7 @@
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 @@
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 @@
ProfileSummaryInfo *ProfileSummaryInfoWrapperPass::getPSI(Module &M) {
if (!PSI)
- PSI.reset(new ProfileSummaryInfo(M));
+ PSI.reset(new ProfileSummaryInfo(&M));
+ else
+ PSI->resetM(&M);
return PSI.get();
}
@@ -142,7 +151,7 @@
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
Index: include/llvm/Analysis/ProfileSummaryInfo.h
===================================================================
--- include/llvm/Analysis/ProfileSummaryInfo.h
+++ include/llvm/Analysis/ProfileSummaryInfo.h
@@ -40,15 +40,15 @@
// units. This would require making this depend on BFI.
class ProfileSummaryInfo {
private:
- Module &M;
+ Module *M;
std::unique_ptr<ProfileSummary> Summary;
void computeSummary();
void computeThresholds();
// Count thresholds to answer isHotCount and isColdCount queries.
Optional<uint64_t> HotCountThreshold, ColdCountThreshold;
public:
- ProfileSummaryInfo(Module &M) : M(M) {}
+ ProfileSummaryInfo(Module *M) : M(M) {}
ProfileSummaryInfo(ProfileSummaryInfo &&Arg)
: M(Arg.M), Summary(std::move(Arg.Summary)) {}
/// \brief Returns true if \p F is a hot function.
@@ -59,6 +59,8 @@
bool isHotCount(uint64_t C);
/// \brief Returns true if count \p C is considered cold.
bool isColdCount(uint64_t C);
+ /// \brief Checks if \p newM is up-to-date, if not, invalidate Summary.
+ void resetModule(Module *NewM);
};
/// An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24993.72744.patch
Type: text/x-patch
Size: 2561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160928/202c6512/attachment.bin>
More information about the llvm-commits
mailing list