[PATCH] D149124: [llvm-profdata] ProfileReader cleanup - preparation for MD5 refactoring - 3

William Junda Huang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 11 13:21:39 PDT 2023


huangjd updated this revision to Diff 521424.
huangjd added a comment.

- Added comments and assert


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149124/new/

https://reviews.llvm.org/D149124

Files:
  llvm/lib/ProfileData/SampleProfReader.cpp


Index: llvm/lib/ProfileData/SampleProfReader.cpp
===================================================================
--- llvm/lib/ProfileData/SampleProfReader.cpp
+++ llvm/lib/ProfileData/SampleProfReader.cpp
@@ -765,9 +765,8 @@
   // If profile is CS, the function offset section is expected to consist of
   // sequences of contexts in pre-order layout
   // (e.g. [A, A:1 @ B, A:1 @ B:2.3 @ C] [D, D:1 @ E]), so that when a matched
-  // context in the module is found, the profiles of all its prefix contexts (
-  // all callers on the call stack) are loaded. A list is needed since the order
-  // of profiles matters.
+  // context in the module is found, the profiles of all its callees are
+  // recursively loaded. A list is needed since the order of profiles matters.
   if (ProfileIsCS)
     return true;
 
@@ -861,6 +860,7 @@
     }
 
     if (ProfileIsCS) {
+      assert(useFuncOffsetList());
       DenseSet<uint64_t> FuncGuidsToUse;
       if (useMD5()) {
         for (auto Name : FuncsToUse)
@@ -898,6 +898,7 @@
         }
       }
     } else if (useMD5()) {
+      assert(!useFuncOffsetList());
       for (auto Name : FuncsToUse) {
         auto GUID = std::to_string(MD5Hash(Name));
         auto iter = FuncOffsetTable.find(StringRef(GUID));
@@ -908,6 +909,7 @@
           return EC;
       }
     } else if (Remapper) {
+      assert(useFuncOffsetList());
       for (auto NameOffset : FuncOffsetList) {
         SampleContext FContext(NameOffset.first);
         auto FuncName = FContext.getName();
@@ -918,6 +920,7 @@
           return EC;
       }
     } else {
+      assert(!useFuncOffsetList());
       for (auto Name : FuncsToUse) {
         auto iter = FuncOffsetTable.find(Name);
         if (iter == FuncOffsetTable.end())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149124.521424.patch
Type: text/x-patch
Size: 1757 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230511/19bf53b3/attachment.bin>


More information about the llvm-commits mailing list