[clang] [llvm] [Offloading] Extend OffloadBinary format to support multiple metadata entries (PR #169425)

Yury Plyakhin via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 1 19:19:31 PST 2025


================
@@ -82,76 +116,79 @@ class OffloadBinary : public Binary {
   LLVM_ABI static Expected<std::unique_ptr<OffloadBinary>>
       create(MemoryBufferRef);
 
-  /// Serialize the contents of \p File to a binary buffer to be read later.
-  LLVM_ABI static SmallString<0> write(const OffloadingImage &);
+  /// Serialize the contents of \p OffloadingData to a binary buffer to be read
+  /// later.
+  LLVM_ABI static SmallString<0>
+  write(ArrayRef<OffloadingImage> OffloadingData);
 
   static uint64_t getAlignment() { return 8; }
 
-  ImageKind getImageKind() const { return TheEntry->TheImageKind; }
-  OffloadKind getOffloadKind() const { return TheEntry->TheOffloadKind; }
+  ImageKind getOnlyImageKind() const {
+    assert(getEntriesCount() == 1 && "Expected exactly one entry.");
+    return Entries[0].first->TheImageKind;
+  }
+
+  OffloadKind getOffloadKind() const { return Entries[0].first->TheOffloadKind; }
   uint32_t getVersion() const { return TheHeader->Version; }
-  uint32_t getFlags() const { return TheEntry->Flags; }
+  uint32_t getFlags() const { return Entries[0].first->Flags; }
----------------
YuriPlyakhin wrote:

I removed this getter for now.

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


More information about the llvm-commits mailing list