[llvm] [ctx_prof] Make the profile output analyzable by llvm-bcanalyzer (PR #99563)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 09:02:20 PDT 2024


================
@@ -139,6 +140,18 @@ PGOCtxProfileReader::readContext(bool ExpectIndex) {
 }
 
 Error PGOCtxProfileReader::readMetadata() {
+  if (Magic.size() < PGOCtxProfileWriter::ContainerMagic.size() ||
+      Magic != PGOCtxProfileWriter::ContainerMagic)
+    return make_error<InstrProfError>(instrprof_error::invalid_prof,
+                                      "Invalid magic");
+
+  BitstreamEntry Entry;
+  RET_ON_ERR(Cursor.advance().moveInto(Entry));
+  if (Entry.Kind != BitstreamEntry::SubBlock ||
+      Entry.ID != bitc::BLOCKINFO_BLOCK_ID)
+    return unsupported("Expected Block ID");
+  RET_ON_ERR(Cursor.SkipBlock());
----------------
teresajohnson wrote:

Can you add a comment about why calling SkipBlock?

https://github.com/llvm/llvm-project/pull/99563


More information about the llvm-commits mailing list