[llvm] [Exegesis] Add supports to serialize/deserialize object files into benchmarks (PR #121993)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 16:00:11 PST 2025
================
@@ -364,6 +403,52 @@ Benchmark::readTriplesAndCpusFromYamls(MemoryBufferRef Buffer) {
return Result;
}
+Error Benchmark::setObjectFile(StringRef RawBytes) {
+ SmallVector<uint8_t> CompressedBytes;
+ llvm::compression::Format CompressionFormat;
+
+ auto isFormatAvailable = [](llvm::compression::Format F) -> bool {
+ switch (F) {
+ case compression::Format::Zstd:
+ return compression::zstd::isAvailable();
+ case compression::Format::Zlib:
+ return compression::zlib::isAvailable();
+ }
+ };
+ if (ForceObjectFileCompressionFormat.getNumOccurrences() > 0) {
+ CompressionFormat = ForceObjectFileCompressionFormat;
+ if (!isFormatAvailable(CompressionFormat))
+ return make_error<StringError>(
+ "The designated compression format is not available.",
+ inconvertibleErrorCode());
+ } else if (isFormatAvailable(compression::Format::Zstd)) {
+ // Try newer compression algorithm first.
+ CompressionFormat = compression::Format::Zstd;
+ } else if (isFormatAvailable(compression::Format::Zlib)) {
+ CompressionFormat = compression::Format::Zlib;
+ } else {
+ return make_error<StringError>(
+ "None of the compression methods is available.",
----------------
topperc wrote:
is -> are
https://github.com/llvm/llvm-project/pull/121993
More information about the llvm-commits
mailing list