[llvm] 6552948 - [memprof] Use unknown_function error type for missing functions

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Wed May 4 13:02:46 PDT 2022


Author: Teresa Johnson
Date: 2022-05-04T13:02:30-07:00
New Revision: 655294866cf8fa719b240a7e9fe51de9a2c48ddc

URL: https://github.com/llvm/llvm-project/commit/655294866cf8fa719b240a7e9fe51de9a2c48ddc
DIFF: https://github.com/llvm/llvm-project/commit/655294866cf8fa719b240a7e9fe51de9a2c48ddc.diff

LOG: [memprof] Use unknown_function error type for missing functions

Switch the error type when a function is not found in the memprof
profile to unknown_function. This gives compatibility with normal PGO
function matching, and also prevents issuing large numbers of additional
matching errors since pgo-warn-missing-function is off by default.

Differential Revision: https://reviews.llvm.org/D124953

Added: 
    

Modified: 
    llvm/lib/ProfileData/InstrProfReader.cpp
    llvm/unittests/ProfileData/InstrProfTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 88de3385273c9..ee8989979a26e 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -1050,9 +1050,9 @@ IndexedInstrProfReader::getMemProfRecord(const uint64_t FuncNameHash) {
                                       "no memprof data available in profile");
   auto Iter = MemProfRecordTable->find(FuncNameHash);
   if (Iter == MemProfRecordTable->end())
-    return make_error<InstrProfError>(instrprof_error::hash_mismatch,
-                                      "memprof record not found for hash " +
-                                          Twine(FuncNameHash));
+    return make_error<InstrProfError>(
+        instrprof_error::unknown_function,
+        "memprof record not found for function hash " + Twine(FuncNameHash));
 
   // Setup a callback to convert from frame ids to frame using the on-disk
   // FrameData hash table.

diff  --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index e40bc82b8bf05..e097b374224e0 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -352,8 +352,15 @@ TEST_F(InstrProfTest, test_memprof_getrecord_error) {
   auto Profile = Writer.writeBuffer();
   readProfile(std::move(Profile));
 
+  // Missing frames give a hash_mismatch error.
   auto RecordOr = Reader->getMemProfRecord(0x9999);
-  EXPECT_THAT_ERROR(RecordOr.takeError(), Failed());
+  ASSERT_TRUE(
+      ErrorEquals(instrprof_error::hash_mismatch, RecordOr.takeError()));
+
+  // Missing functions give a unknown_function error.
+  RecordOr = Reader->getMemProfRecord(0x1111);
+  ASSERT_TRUE(
+      ErrorEquals(instrprof_error::unknown_function, RecordOr.takeError()));
 }
 
 TEST_F(InstrProfTest, test_memprof_merge) {


        


More information about the llvm-commits mailing list