[PATCH] D124953: [memprof] Use unknown_function error type for missing functions

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


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG655294866cf8: [memprof] Use unknown_function error type for missing functions (authored by tejohnson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124953

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


Index: llvm/unittests/ProfileData/InstrProfTest.cpp
===================================================================
--- llvm/unittests/ProfileData/InstrProfTest.cpp
+++ llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -352,8 +352,15 @@
   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) {
Index: llvm/lib/ProfileData/InstrProfReader.cpp
===================================================================
--- llvm/lib/ProfileData/InstrProfReader.cpp
+++ llvm/lib/ProfileData/InstrProfReader.cpp
@@ -1050,9 +1050,9 @@
                                       "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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124953.427115.patch
Type: text/x-patch
Size: 1701 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220504/eac7d8e4/attachment.bin>


More information about the llvm-commits mailing list