[Openmp-commits] [openmp] [Libomptarget] Rework image checking further (PR #76120)
Jan Patrick Lehr via Openmp-commits
openmp-commits at lists.llvm.org
Thu Dec 21 06:08:07 PST 2023
================
@@ -330,24 +330,18 @@ JITEngine::process(const __tgt_device_image &Image,
return &Image;
}
-bool JITEngine::checkBitcodeImage(const __tgt_device_image &Image) {
+Expected<bool> JITEngine::checkBitcodeImage(StringRef Buffer) const {
TimeTraceScope TimeScope("Check bitcode image");
- if (!isImageBitcode(Image))
- return false;
-
- StringRef Data(reinterpret_cast<const char *>(Image.ImageStart),
- target::getPtrDiff(Image.ImageEnd, Image.ImageStart));
- auto MB = MemoryBuffer::getMemBuffer(Data, /*BufferName=*/"",
- /*RequiresNullTerminator=*/false);
- if (!MB)
- return false;
+ assert(identify_magic(Buffer) == file_magic::bitcode &&
+ "Input is not bitcode");
LLVMContext Context;
- SMDiagnostic Diagnostic;
- std::unique_ptr<Module> M =
- llvm::getLazyIRModule(std::move(MB), Diagnostic, Context,
- /*ShouldLazyLoadMetadata=*/true);
+ auto ModuleOrErr = getLazyBitcodeModule(MemoryBufferRef(Buffer, ""), Context,
+ /*ShouldLazyLoadMetadata=*/false);
----------------
jplehr wrote:
Thanks for explaining, and sorry for confusion. I was asking for the parameter about "ShouldLazyLoadMetadata". Why has that changed to false?
https://github.com/llvm/llvm-project/pull/76120
More information about the Openmp-commits
mailing list