================
@@ -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));
----------------
mingmingl-llvm wrote:

done!

https://github.com/llvm/llvm-project/pull/162388#discussion_r2430457960 makes 
enum class definition to be `signed int`. Since we use conditions here, the 
enum class definition could be signed or unsigned int. I'm open to both.

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

Reply via email to