================
@@ -102,13 +124,48 @@ StaticDataProfileInfo::getConstantProfileCount(const
Constant *C) const {
StringRef StaticDataProfileInfo::getConstantSectionPrefix(
const Constant *C, const ProfileSummaryInfo *PSI) const {
std::optional<uint64_t> Count = getConstantProfileCount(C);
+
+ if (EnableDataAccessProf) {
+ // Module flag `HasDataAccessProf` is 1 -> empty section prefix means
+ // unknown hotness except for string literals.
+ if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(C);
+ GV && llvm::memprof::IsAnnotationOK(*GV) &&
+ !GV->getName().starts_with(".str")) {
+ auto HotnessFromDAP = getSectionHotnessUsingDAP(GV->getSectionPrefix());
+
+ if (!Count) {
+ StringRef Prefix = hotnessToStr(HotnessFromDAP);
+ LLVM_DEBUG(dbgs() << GV->getName() << "has section prefix "
+ << debugPrintSectionPrefix(Prefix)
+ << ", solely from data access profiles\n");
+ return Prefix;
+ }
+
+ // Both DAP and PGO counters are available. Use the hotter one.
+ auto HotnessFromPGO = getSectionHotnessUsingProfileCount(C, PSI, *Count);
+ StringRef Prefix = hotnessToStr(std::max(HotnessFromDAP,
HotnessFromPGO));
----------------
snehasish wrote:
Using std::max on the enum values is a bit hard to reason about. Could we use a
condition here?
https://github.com/llvm/llvm-project/pull/163325
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits