[PATCH] D56203: [IRReader] Expose getLazyIRModule
Scott Linder via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 2 09:14:10 PST 2019
scott.linder created this revision.
scott.linder added reviewers: aprantl, yaxunl, espindola.
Herald added a subscriber: llvm-commits.
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 <https://reviews.llvm.org/rL212364>; I don't have all of the context for the original change, but I don't see why this function can't be exposed now, especially with the stronger type signature it currently has.
Repository:
rL LLVM
https://reviews.llvm.org/D56203
Files:
include/llvm/IRReader/IRReader.h
lib/IRReader/IRReader.cpp
Index: lib/IRReader/IRReader.cpp
===================================================================
--- lib/IRReader/IRReader.cpp
+++ lib/IRReader/IRReader.cpp
@@ -30,9 +30,9 @@
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(
Index: include/llvm/IRReader/IRReader.h
===================================================================
--- include/llvm/IRReader/IRReader.h
+++ include/llvm/IRReader/IRReader.h
@@ -21,11 +21,21 @@
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.
+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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56203.179855.patch
Type: text/x-patch
Size: 2014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190102/bd5765f7/attachment.bin>
More information about the llvm-commits
mailing list