Skip to content

Commit 890335b

Browse files
authored
[InstrProf] Do not block functions from PGOUse (#71106)
The `skipPGO()` function was added in https://reviews.llvm.org/D137184. Unfortunately, it also blocked functions from being annotated (PGOUse), which I believe will cause confusion to users if a function has a profile but it is not PGO'd. The docs for `noprofile` and `skipprofile` only claim to block instrumentation, not PGO optimization: https://llvm.org/docs/LangRef.html
1 parent 778a484 commit 890335b

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,17 +1760,10 @@ static void collectComdatMembers(
17601760
ComdatMembers.insert(std::make_pair(C, &GA));
17611761
}
17621762

1763-
// Don't perform PGO instrumeatnion / profile-use.
1764-
static bool skipPGO(const Function &F) {
1763+
// Return true if we should not find instrumentation data for this function
1764+
static bool skipPGOUse(const Function &F) {
17651765
if (F.isDeclaration())
17661766
return true;
1767-
if (F.hasFnAttribute(llvm::Attribute::NoProfile))
1768-
return true;
1769-
if (F.hasFnAttribute(llvm::Attribute::SkipProfile))
1770-
return true;
1771-
if (F.getInstructionCount() < PGOFunctionSizeThreshold)
1772-
return true;
1773-
17741767
// If there are too many critical edges, PGO might cause
17751768
// compiler time problem. Skip PGO if the number of
17761769
// critical edges execeed the threshold.
@@ -1788,7 +1781,19 @@ static bool skipPGO(const Function &F) {
17881781
<< " exceed the threshold. Skip PGO.\n");
17891782
return true;
17901783
}
1784+
return false;
1785+
}
17911786

1787+
// Return true if we should not instrument this function
1788+
static bool skipPGOGen(const Function &F) {
1789+
if (skipPGOUse(F))
1790+
return true;
1791+
if (F.hasFnAttribute(llvm::Attribute::NoProfile))
1792+
return true;
1793+
if (F.hasFnAttribute(llvm::Attribute::SkipProfile))
1794+
return true;
1795+
if (F.getInstructionCount() < PGOFunctionSizeThreshold)
1796+
return true;
17921797
return false;
17931798
}
17941799

@@ -1804,7 +1809,7 @@ static bool InstrumentAllFunctions(
18041809
collectComdatMembers(M, ComdatMembers);
18051810

18061811
for (auto &F : M) {
1807-
if (skipPGO(F))
1812+
if (skipPGOGen(F))
18081813
continue;
18091814
auto &TLI = LookupTLI(F);
18101815
auto *BPI = LookupBPI(F);
@@ -2031,7 +2036,7 @@ static bool annotateAllFunctions(
20312036
InstrumentFuncEntry = PGOInstrumentEntry;
20322037
bool HasSingleByteCoverage = PGOReader->hasSingleByteCoverage();
20332038
for (auto &F : M) {
2034-
if (skipPGO(F))
2039+
if (skipPGOUse(F))
20352040
continue;
20362041
auto &TLI = LookupTLI(F);
20372042
auto *BPI = LookupBPI(F);

0 commit comments

Comments
 (0)