[llvm] r353755 - [IRReader] Expose getLazyIRModule
Scott Linder via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 11 14:01:14 PST 2019
Author: scott.linder
Date: Mon Feb 11 14:01:13 2019
New Revision: 353755
URL: http://llvm.org/viewvc/llvm-project?rev=353755&view=rev
Log:
[IRReader] Expose getLazyIRModule
Currently there is no way to lazy-load an in-memory IR module without
first writing it to disk. This patch just exposes the existing
implementation of getLazyIRModule.
This is effectively a revert of rL212364
Differential Revision: https://reviews.llvm.org/D56203
Modified:
llvm/trunk/include/llvm/IRReader/IRReader.h
llvm/trunk/lib/IRReader/IRReader.cpp
Modified: llvm/trunk/include/llvm/IRReader/IRReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IRReader/IRReader.h?rev=353755&r1=353754&r2=353755&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IRReader/IRReader.h (original)
+++ llvm/trunk/include/llvm/IRReader/IRReader.h Mon Feb 11 14:01:13 2019
@@ -20,11 +20,22 @@
namespace llvm {
class StringRef;
+class MemoryBuffer;
class MemoryBufferRef;
class Module;
class SMDiagnostic;
class LLVMContext;
+/// If the given MemoryBuffer holds a bitcode image, return a Module
+/// for it which does lazy deserialization of function bodies. Otherwise,
+/// attempt to parse it as LLVM Assembly and return a fully populated
+/// Module. The ShouldLazyLoadMetadata flag is passed down to the bitcode
+/// reader to optionally enable lazy metadata loading. This takes ownership
+/// of \p Buffer.
+std::unique_ptr<Module> getLazyIRModule(std::unique_ptr<MemoryBuffer> Buffer,
+ SMDiagnostic &Err, LLVMContext &Context,
+ bool ShouldLazyLoadMetadata = false);
+
/// If the given file holds a bitcode image, return a Module
/// for it which does lazy deserialization of function bodies. Otherwise,
/// attempt to parse it as LLVM Assembly and return a fully populated
Modified: llvm/trunk/lib/IRReader/IRReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IRReader/IRReader.cpp?rev=353755&r1=353754&r2=353755&view=diff
==============================================================================
--- llvm/trunk/lib/IRReader/IRReader.cpp (original)
+++ llvm/trunk/lib/IRReader/IRReader.cpp Mon Feb 11 14:01:13 2019
@@ -29,9 +29,9 @@ static const char *const TimeIRParsingGr
static const char *const TimeIRParsingName = "parse";
static const char *const TimeIRParsingDescription = "Parse IR";
-static std::unique_ptr<Module>
-getLazyIRModule(std::unique_ptr<MemoryBuffer> Buffer, SMDiagnostic &Err,
- LLVMContext &Context, bool ShouldLazyLoadMetadata) {
+std::unique_ptr<Module>
+llvm::getLazyIRModule(std::unique_ptr<MemoryBuffer> Buffer, SMDiagnostic &Err,
+ LLVMContext &Context, bool ShouldLazyLoadMetadata) {
if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
(const unsigned char *)Buffer->getBufferEnd())) {
Expected<std::unique_ptr<Module>> ModuleOrErr = getOwningLazyBitcodeModule(
More information about the llvm-commits
mailing list