use virtual file with llvm::MemoryBuffer::getFileOrSTDIN instead of real file

Dear LLVM-Developers,

we extend the cling C++ interpreter () with CUDA functionality for Nvidia GPUs.

Now we are refactoring the extension () to fix some conceptual errors and improve performance. One of our goals is to avoid file I/O. We have achieved this goal with one exception. We need to write the CUDA fatbinary code to a file because the CodeGen of the CUDA x86 backend uses a file path and uses llvm::MemoryBuffer::getFileOrSTDIN() to load the code from a file. See:

Our question is, can we pass the fatbinary code to CodeGen without file I/O and without changing the source code of clang? We want to avoid changes in the clang code, as it would make it more complicated to update clang/LLVM base. Maybe something is possible with the llvm virtual file system. Unfortunately, I am not familiar enough with it to find a solution.

Thank you so much for your help.

Best regards,
Simeon Ehrig