mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Handle MaterializeAll in getLazyBitcodeModuleImpl. NFC.
This just handles both cases in the same place. Extracted from a patch by Karl Schimpf. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239870 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4a4558e436
commit
485973a45e
@ -4603,11 +4603,11 @@ const std::error_category &llvm::BitcodeErrorCategory() {
|
|||||||
/// \a parseBitcodeFile(). If this is truly lazy, then we need to eagerly pull
|
/// \a parseBitcodeFile(). If this is truly lazy, then we need to eagerly pull
|
||||||
/// in forward-referenced functions from block address references.
|
/// in forward-referenced functions from block address references.
|
||||||
///
|
///
|
||||||
/// \param[in] WillMaterializeAll Set to \c true if the caller promises to
|
/// \param[in] MaterializeAll Set to \c true if we should materialize
|
||||||
/// materialize everything -- in particular, if this isn't truly lazy.
|
/// everything.
|
||||||
static ErrorOr<std::unique_ptr<Module>>
|
static ErrorOr<std::unique_ptr<Module>>
|
||||||
getLazyBitcodeModuleImpl(std::unique_ptr<MemoryBuffer> &&Buffer,
|
getLazyBitcodeModuleImpl(std::unique_ptr<MemoryBuffer> &&Buffer,
|
||||||
LLVMContext &Context, bool WillMaterializeAll,
|
LLVMContext &Context, bool MaterializeAll,
|
||||||
DiagnosticHandlerFunction DiagnosticHandler,
|
DiagnosticHandlerFunction DiagnosticHandler,
|
||||||
bool ShouldLazyLoadMetadata = false) {
|
bool ShouldLazyLoadMetadata = false) {
|
||||||
std::unique_ptr<Module> M =
|
std::unique_ptr<Module> M =
|
||||||
@ -4626,10 +4626,15 @@ getLazyBitcodeModuleImpl(std::unique_ptr<MemoryBuffer> &&Buffer,
|
|||||||
R->parseBitcodeInto(nullptr, M.get(), ShouldLazyLoadMetadata))
|
R->parseBitcodeInto(nullptr, M.get(), ShouldLazyLoadMetadata))
|
||||||
return cleanupOnError(EC);
|
return cleanupOnError(EC);
|
||||||
|
|
||||||
if (!WillMaterializeAll)
|
if (MaterializeAll) {
|
||||||
|
// Read in the entire module, and destroy the BitcodeReader.
|
||||||
|
if (std::error_code EC = M->materializeAllPermanently())
|
||||||
|
return EC;
|
||||||
|
} else {
|
||||||
// Resolve forward references from blockaddresses.
|
// Resolve forward references from blockaddresses.
|
||||||
if (std::error_code EC = R->materializeForwardReferencedFunctions())
|
if (std::error_code EC = R->materializeForwardReferencedFunctions())
|
||||||
return cleanupOnError(EC);
|
return cleanupOnError(EC);
|
||||||
|
}
|
||||||
|
|
||||||
Buffer.release(); // The BitcodeReader owns it now.
|
Buffer.release(); // The BitcodeReader owns it now.
|
||||||
return std::move(M);
|
return std::move(M);
|
||||||
@ -4657,19 +4662,10 @@ ErrorOr<std::unique_ptr<Module>>
|
|||||||
llvm::parseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context,
|
llvm::parseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context,
|
||||||
DiagnosticHandlerFunction DiagnosticHandler) {
|
DiagnosticHandlerFunction DiagnosticHandler) {
|
||||||
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);
|
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);
|
||||||
ErrorOr<std::unique_ptr<Module>> ModuleOrErr = getLazyBitcodeModuleImpl(
|
return getLazyBitcodeModuleImpl(std::move(Buf), Context, true,
|
||||||
std::move(Buf), Context, true, DiagnosticHandler);
|
DiagnosticHandler);
|
||||||
if (!ModuleOrErr)
|
|
||||||
return ModuleOrErr;
|
|
||||||
std::unique_ptr<Module> &M = ModuleOrErr.get();
|
|
||||||
// Read in the entire module, and destroy the BitcodeReader.
|
|
||||||
if (std::error_code EC = M->materializeAllPermanently())
|
|
||||||
return EC;
|
|
||||||
|
|
||||||
// TODO: Restore the use-lists to the in-memory state when the bitcode was
|
// TODO: Restore the use-lists to the in-memory state when the bitcode was
|
||||||
// written. We must defer until the Module has been fully materialized.
|
// written. We must defer until the Module has been fully materialized.
|
||||||
|
|
||||||
return std::move(M);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
Loading…
Reference in New Issue
Block a user