[compiler-rt] [llvm] [InstrProf] Add debuginfod correlation support (PR #106606)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 10:16:57 PDT 2024


================
@@ -113,11 +115,36 @@ InstrProfCorrelator::get(StringRef Filename, ProfCorrelatorKind FileKind) {
     return get(std::move(*BufferOrErr), FileKind);
   }
   if (FileKind == BINARY) {
-    auto BufferOrErr = errorOrToExpected(MemoryBuffer::getFile(Filename));
-    if (auto Err = BufferOrErr.takeError())
-      return std::move(Err);
+    if (!Filename.empty()) {
+      auto BufferOrErr = errorOrToExpected(MemoryBuffer::getFile(Filename));
+      if (auto Err = BufferOrErr.takeError())
+        return std::move(Err);
+      return get(std::move(*BufferOrErr), FileKind);
+    } else if (BIDFetcher) {
+      if (BIs->size() > 1)
+        return make_error<InstrProfError>(
+            instrprof_error::unable_to_correlate_profile,
+            "unsupported profile binary correlation when there are multiple "
+            "build IDs in a binary");
 
-    return get(std::move(*BufferOrErr), FileKind);
+      std::optional<std::string> Path = BIDFetcher->fetch(BIs->front());
+      if (Path) {
+        auto BufferOrErr = errorOrToExpected(MemoryBuffer::getFile(*Path));
+        if (auto Err = BufferOrErr.takeError())
+          return std::move(Err);
+        return get(std::move(*BufferOrErr), BINARY);
+      } else {
----------------
gulfemsavrun wrote:

Done.

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


More information about the llvm-commits mailing list