[PATCH] LLVM changes for indirect call target profiling support

Betul Buyukkurt betulb at codeaurora.org
Thu May 14 10:07:30 PDT 2015


================
Comment at: include/llvm/ProfileData/InstrProf.h:27
@@ +26,3 @@
+    indirect_call_target = 0,
+    last = 1
+};
----------------
davidxl wrote:
> I suggest change it to 3 with reserved slots for new value profiler in the future.
Reservation is not necessary. The current readers/writers and runtime will handle nay additions here w/o any format version change being necessary. Changes will have to happen in the InstrProfiling.cpp in lib/Transforms/Instrumentation to allow the generation of the additional entries.

================
Comment at: include/llvm/ProfileData/InstrProfReader.h:318
@@ +317,3 @@
+
+      if (++I >= NumEntries)
+        return data_type();
----------------
davidxl wrote:
> Error handling?
Answered below.

================
Comment at: include/llvm/ProfileData/InstrProfReader.h:329
@@ +328,3 @@
+      // If we have more counts than data, this is bogus.
+      if (I + NumCounts > NumEntries)
+        return data_type();
----------------
davidxl wrote:
> No error handling or warning? 
Errors are handled elsewhere. So the empty data_type() return is done intentionally here. When the getFunctionCounts method sees an empty InstrProfRecord, then it emits malformed data error (code copied below). 

  // Found it. Look for counters with the right hash.
  ArrayRef<InstrProfRecord> Data = (*Iter);
  if (Data.empty())
    return error(instrprof_error::malformed);



================
Comment at: include/llvm/ProfileData/InstrProfReader.h:367
@@ +366,3 @@
+        if (D - Start + 2 * sizeof(uint32_t) > N)
+          return data_type();
+        uint32_t ValueKind = endian::readNext<uint32_t, little, unaligned>(D);
----------------
davidxl wrote:
> All the errors related corrupted data should be handled somewhere, e.g, jumping to  common error handling label...
They are handled in the getFunctionCounts(). Explained above.

http://reviews.llvm.org/D8908

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list