[PATCH] D108942: [compiler-rt] Add more diagnostic to InstrProfError

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 26 10:09:52 PDT 2021


phosek added inline comments.


================
Comment at: llvm/lib/ProfileData/InstrProf.cpp:153
+  if (!ErrMsg.empty())
+    OS << " : " << ErrMsg;
+
----------------
I'd omit the space here.


================
Comment at: llvm/lib/ProfileData/InstrProfReader.cpp:273
   if ((Line++)->getAsInteger(0, Record.Hash))
-    return error(instrprof_error::malformed);
+    return error(instrprof_error::malformed, "function hash is invalid");
 
----------------
We could provide some additional details.


================
Comment at: llvm/lib/ProfileData/InstrProfReader.cpp:280
   if ((Line++)->getAsInteger(10, NumCounters))
-    return error(instrprof_error::malformed);
+    return error(instrprof_error::malformed, "number of counters is invalid");
   if (NumCounters == 0)
----------------



================
Comment at: llvm/lib/ProfileData/InstrProfReader.cpp:292
     if ((Line++)->getAsInteger(10, Count))
-      return error(instrprof_error::malformed);
+      return error(instrprof_error::malformed, "count is invalid");
     Record.Counts.push_back(Count);
----------------



================
Comment at: llvm/lib/ProfileData/InstrProfReader.cpp:342
+    return make_error<InstrProfError>(instrprof_error::malformed,
+                                      "padding is missing");
   // The magic should have the same byte order as in the previous header.
----------------
There might still be some padding, just not the right amount.


================
Comment at: llvm/lib/ProfileData/InstrProfReader.cpp:450
   if (MaxNumCounters < 0 || NumCounters > (uint32_t)MaxNumCounters)
-    return error(instrprof_error::malformed);
+    return error(instrprof_error::malformed, "counter pointer is invalid");
 
----------------



================
Comment at: llvm/lib/ProfileData/InstrProfReader.cpp:462
       ((uint32_t)CounterOffset + NumCounters) > (uint32_t)MaxNumCounters)
-    return error(instrprof_error::malformed);
+    return error(instrprof_error::malformed, "counter offset is invalid");
 
----------------



================
Comment at: llvm/lib/ProfileData/InstrProfReader.cpp:553
+          instrprof_error::malformed,
+          "not enough space to read binary id length");
 
----------------



================
Comment at: llvm/lib/ProfileData/InstrProfReader.cpp:562
+          instrprof_error::malformed,
+          "not enough space to read binary id data");
 
----------------



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108942



More information about the llvm-commits mailing list