================
@@ -181,7 +195,7 @@ class OffloadFile : public OwningBinary<OffloadBinary> {
         getBinary()->getMemoryBufferRef().getBufferIdentifier());
 
     // This parsing should never fail because it has already been parsed.
-    auto NewBinaryOrErr = OffloadBinary::create(*Buffer);
+    auto NewBinaryOrErr = OffloadBinary::createV1(*Buffer);
----------------
YuriPlyakhin wrote:

OffloadFile::copy is a deep copy used to create a copy of OffloadBinary for 
specific target (to split binaries into sets of compatible target binaries). 
Currently copy method is using OffloadBinary::create to create such Binary from 
a Buffer.

In new OffloadBinary format Buffer may contain multiple entries/images for 
non-compatible targets. Per my understanding of usage model, we still want to 
be able to do an OffloadFile:copy for just 1 single entry/image (even if buffer 
would be shared between multiple incompatible target binaries) and hence create 
method should be able to create an OffloadFile, which would have shared buffer 
with other OffloadFile objects, but it would contain only 1 entry/image pointer 
or something.

Hence, I'm thinking of creating something like this: 
```
  LLVM_ABI static Expected<std::unique_ptr<OffloadBinary>>
      create(MemoryBufferRef Buf, index Num = 0);
```
So, for old OffloadBinary, we would not need index, but for new OffloadBinary 
we would be able to create one OffloadBinary with shared buffer.
Hence extractOffloadFiles creates multiple binaries (either with own buffer 
each for old format or with shared buffer between binaries for new format)

https://github.com/llvm/llvm-project/pull/169425
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to