[compiler-rt] [llvm] [InstrProf] Add debuginfod correlation support (PR #106606)
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 30 18:38: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 {
----------------
ellishg wrote:
If you use `if (!Path)` you can early return on the error case and remove the need to keep the above code inside an if block. I'm just trying to reduce indentation to make the code easier to read.
https://github.com/llvm/llvm-project/pull/106606
More information about the llvm-commits
mailing list