[PATCH] D54212: [PGO] early exit if all count values are zero
Rong Xu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 7 10:08:07 PST 2018
xur updated this revision to Diff 172978.
xur added a comment.
set entry count
https://reviews.llvm.org/D54212
Files:
PGOInstrumentation.cpp
Index: PGOInstrumentation.cpp
===================================================================
--- PGOInstrumentation.cpp
+++ PGOInstrumentation.cpp
@@ -859,7 +859,7 @@
FreqAttr(FFA_Normal) {}
// Read counts for the instrumented BB from profile.
- bool readCounters(IndexedInstrProfReader *PGOReader);
+ bool readCounters(IndexedInstrProfReader *PGOReader, bool &AllZeros);
// Populate the counts for all BBs.
void populateCounters();
@@ -904,6 +904,7 @@
FuncInfo.dumpInfo(Str);
}
+ uint64_t getProgramMaxCount() const { return ProgramMaxCount; }
private:
Function &F;
Module *M;
@@ -1013,7 +1014,7 @@
// Read the profile from ProfileFileName and assign the value to the
// instrumented BB and the edges. This function also updates ProgramMaxCount.
// Return true if the profile are successfully read, and false on errors.
-bool PGOUseFunc::readCounters(IndexedInstrProfReader *PGOReader) {
+bool PGOUseFunc::readCounters(IndexedInstrProfReader *PGOReader, bool &AllZeros) {
auto &Ctx = M->getContext();
Expected<InstrProfRecord> Result =
PGOReader->getInstrProfRecord(FuncInfo.FuncName, FuncInfo.FunctionHash);
@@ -1053,6 +1054,7 @@
LLVM_DEBUG(dbgs() << " " << I << ": " << CountFromProfile[I] << "\n");
ValueSum += CountFromProfile[I];
}
+ AllZeros = (ValueSum == 0);
LLVM_DEBUG(dbgs() << "SUM = " << ValueSum << "\n");
@@ -1477,8 +1479,15 @@
// later in getInstrBB() to avoid invalidating it.
SplitIndirectBrCriticalEdges(F, BPI, BFI);
PGOUseFunc Func(F, &M, ComdatMembers, BPI, BFI);
- if (!Func.readCounters(PGOReader.get()))
+ bool AllZeros = false;
+ if (!Func.readCounters(PGOReader.get(), AllZeros))
continue;
+ if (AllZeros) {
+ F.setEntryCount(ProfileCount(0, Function::PCT_Real));
+ if (Func.getProgramMaxCount() != 0)
+ ColdFunctions.push_back(&F);
+ continue;
+ }
Func.populateCounters();
Func.setBranchWeights();
Func.annotateValueSites();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54212.172978.patch
Type: text/x-patch
Size: 2013 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181107/5251ac3c/attachment.bin>
More information about the llvm-commits
mailing list