[llvm-branch-commits] [llvm-branch] r98641 - in /llvm/branches/Apple/Morbo: ./ include/llvm/Bitcode/ReaderWriter.h include/llvm/ExecutionEngine/ExecutionEngine.h include/llvm/GlobalValue.h include/llvm/ModuleProvider.h include/llvm/PassManager.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Reader/BitcodeReader.h lib/ExecutionEngine/ExecutionEngine.cpp lib/ExecutionEngine/JIT/JIT.cpp lib/VMCore/ModuleProvider.cpp lib/VMCore/PassManager.cpp tools/lli/lli.cpp
Eric Christopher
echristo at apple.com
Tue Mar 16 10:06:03 PDT 2010
Author: echristo
Date: Tue Mar 16 12:06:03 2010
New Revision: 98641
URL: http://llvm.org/viewvc/llvm-project?rev=98641&view=rev
Log:
Merge patches 96832, 96858, 96870, and 96879 from Hermes.
Added:
llvm/branches/Apple/Morbo/include/llvm/ModuleProvider.h
- copied unchanged from r96832, llvm/branches/Apple/Hermes/include/llvm/ModuleProvider.h
llvm/branches/Apple/Morbo/lib/VMCore/ModuleProvider.cpp
- copied, changed from r96832, llvm/branches/Apple/Hermes/lib/VMCore/ModuleProvider.cpp
Modified:
llvm/branches/Apple/Morbo/ (props changed)
llvm/branches/Apple/Morbo/include/llvm/Bitcode/ReaderWriter.h
llvm/branches/Apple/Morbo/include/llvm/ExecutionEngine/ExecutionEngine.h
llvm/branches/Apple/Morbo/include/llvm/GlobalValue.h
llvm/branches/Apple/Morbo/include/llvm/PassManager.h
llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.h
llvm/branches/Apple/Morbo/lib/ExecutionEngine/ExecutionEngine.cpp
llvm/branches/Apple/Morbo/lib/ExecutionEngine/JIT/JIT.cpp
llvm/branches/Apple/Morbo/lib/VMCore/PassManager.cpp
llvm/branches/Apple/Morbo/tools/lli/lli.cpp
Propchange: llvm/branches/Apple/Morbo/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 16 12:06:03 2010
@@ -1,2 +1,2 @@
-/llvm/branches/Apple/Hermes:96876
+/llvm/branches/Apple/Hermes:96832,96858,96870,96876,96879
/llvm/trunk:98602,98604,98612,98615-98616
Modified: llvm/branches/Apple/Morbo/include/llvm/Bitcode/ReaderWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/Bitcode/ReaderWriter.h?rev=98641&r1=98640&r2=98641&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/Bitcode/ReaderWriter.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/Bitcode/ReaderWriter.h Tue Mar 16 12:06:03 2010
@@ -18,12 +18,22 @@
namespace llvm {
class Module;
+ class ModuleProvider;
class MemoryBuffer;
class ModulePass;
class BitstreamWriter;
class LLVMContext;
class raw_ostream;
+ /// getBitcodeModuleProvider - Read the header of the specified bitcode buffer
+ /// and prepare for lazy deserialization of function bodies. If successful,
+ /// this takes ownership of 'buffer' and returns a non-null pointer. On
+ /// error, this returns null, *does not* take ownership of Buffer, and fills
+ /// in *ErrMsg with an error description if ErrMsg is non-null.
+ ModuleProvider *getBitcodeModuleProvider(MemoryBuffer *Buffer,
+ LLVMContext& Context,
+ std::string *ErrMsg = 0);
+
/// getLazyBitcodeModule - Read the header of the specified bitcode buffer
/// and prepare for lazy deserialization of function bodies. If successful,
/// this takes ownership of 'buffer' and returns a non-null pointer. On
Modified: llvm/branches/Apple/Morbo/include/llvm/ExecutionEngine/ExecutionEngine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/ExecutionEngine/ExecutionEngine.h?rev=98641&r1=98640&r2=98641&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/ExecutionEngine/ExecutionEngine.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/ExecutionEngine/ExecutionEngine.h Tue Mar 16 12:06:03 2010
@@ -18,6 +18,7 @@
#include <vector>
#include <map>
#include <string>
+#include "llvm/ModuleProvider.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/ValueMap.h"
@@ -168,6 +169,15 @@
///
/// Clients should make sure to initialize targets prior to calling this
/// function.
+ static ExecutionEngine *createJIT(ModuleProvider *MP,
+ std::string *ErrorStr = 0,
+ JITMemoryManager *JMM = 0,
+ CodeGenOpt::Level OptLevel =
+ CodeGenOpt::Default,
+ bool GVsWithCode = true,
+ CodeModel::Model CMM =
+ CodeModel::Default);
+
static ExecutionEngine *createJIT(Module *M,
std::string *ErrorStr = 0,
JITMemoryManager *JMM = 0,
@@ -177,6 +187,13 @@
CodeModel::Model CMM =
CodeModel::Default);
+ /// addModuleProvider - Add a ModuleProvider to the list of modules that we
+ /// can JIT from. Note that this takes ownership of the ModuleProvider: when
+ /// the ExecutionEngine is destroyed, it destroys the MP as well.
+ virtual void addModuleProvider(ModuleProvider *P) {
+ Modules.push_back(P->getModule());
+ }
+
/// addModule - Add a Module to the list of modules that we can JIT from.
/// Note that this takes ownership of the Module: when the ExecutionEngine is
/// destroyed, it destroys the Module as well.
@@ -189,6 +206,13 @@
const TargetData *getTargetData() const { return TD; }
+
+ /// removeModuleProvider - Remove a ModuleProvider from the list of modules.
+ /// Relases the Module from the ModuleProvider, materializing it in the
+ /// process, and returns the materialized Module.
+ virtual Module* removeModuleProvider(ModuleProvider *P,
+ std::string *ErrInfo = 0);
+
/// removeModule - Remove a Module from the list of modules. Returns true if
/// M is found.
virtual bool removeModule(Module *M);
@@ -438,6 +462,13 @@
public:
/// EngineBuilder - Constructor for EngineBuilder. If create() is called and
+ /// is successful, the created engine takes ownership of the module
+ /// provider.
+ EngineBuilder(ModuleProvider *mp) : M(mp->getModule()) {
+ InitEngine();
+ }
+
+ /// EngineBuilder - Constructor for EngineBuilder. If create() is called and
/// is successful, the created engine takes ownership of the module.
EngineBuilder(Module *m) : M(m) {
InitEngine();
Modified: llvm/branches/Apple/Morbo/include/llvm/GlobalValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/GlobalValue.h?rev=98641&r1=98640&r2=98641&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/GlobalValue.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/GlobalValue.h Tue Mar 16 12:06:03 2010
@@ -215,6 +215,8 @@
/// to see if the function has been read in yet or not.
bool isMaterializable() const;
+ bool hasNotBeenReadFromBitcode() const { return isMaterializable(); }
+
/// isDematerializable - Returns true if this function was loaded from a
/// GVMaterializer that's still attached to its Module and that knows how to
/// dematerialize the function.
Modified: llvm/branches/Apple/Morbo/include/llvm/PassManager.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/PassManager.h?rev=98641&r1=98640&r2=98641&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/PassManager.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/PassManager.h Tue Mar 16 12:06:03 2010
@@ -24,6 +24,7 @@
class Pass;
class ModulePass;
class Module;
+class ModuleProvider;
class PassManagerImpl;
class FunctionPassManagerImpl;
@@ -72,6 +73,7 @@
/// FunctionPassManager ctor - This initializes the pass manager. It needs,
/// but does not take ownership of, the specified Module.
explicit FunctionPassManager(Module *M);
+ explicit FunctionPassManager(ModuleProvider *P);
~FunctionPassManager();
/// add - Add a pass to the queue of passes to run. This passes
Modified: llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.cpp?rev=98641&r1=98640&r2=98641&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.cpp Tue Mar 16 12:06:03 2010
@@ -18,6 +18,7 @@
#include "llvm/InlineAsm.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/Module.h"
+#include "llvm/ModuleProvider.h"
#include "llvm/Operator.h"
#include "llvm/AutoUpgrade.h"
#include "llvm/ADT/SmallString.h"
@@ -1565,6 +1566,10 @@
if (TheModule)
return Error("Multiple MODULE_BLOCKs in same stream");
TheModule = M;
+ if (!TheModule) {
+ TheModule = new Module(Buffer->getBufferIdentifier(), Context);
+ TheModule->setMaterializer(this);
+ }
if (ParseModule())
return true;
break;
@@ -2402,9 +2407,121 @@
//===----------------------------------------------------------------------===//
+// ModuleProvider implementation
+//===----------------------------------------------------------------------===//
+
+
+bool BitcodeReader::materializeFunction(Function *F, std::string *ErrInfo) {
+ // If it already is material, ignore the request.
+ if (!F || !F->isMaterializable()) return false;
+
+ DenseMap<Function*, uint64_t>::iterator DFII = DeferredFunctionInfo.find(F);
+ assert(DFII != DeferredFunctionInfo.end() && "Deferred function not found!");
+
+ // Move the bit stream to the saved position of the deferred function body.
+ Stream.JumpToBit(DFII->second);
+
+ if (ParseFunctionBody(F)) {
+ if (ErrInfo) *ErrInfo = ErrorString;
+ return true;
+ }
+
+ // Upgrade any old intrinsic calls in the function.
+ for (UpgradedIntrinsicMap::iterator I = UpgradedIntrinsics.begin(),
+ E = UpgradedIntrinsics.end(); I != E; ++I) {
+ if (I->first != I->second) {
+ for (Value::use_iterator UI = I->first->use_begin(),
+ UE = I->first->use_end(); UI != UE; ) {
+ if (CallInst* CI = dyn_cast<CallInst>(*UI++))
+ UpgradeIntrinsicCall(CI, I->second);
+ }
+ }
+ }
+
+ return false;
+}
+
+void BitcodeReader::dematerializeFunction(Function *F) {
+ // If this function isn't dematerializable, this is a noop.
+ if (!F || !isDematerializable(F))
+ return;
+
+ assert(DeferredFunctionInfo.count(F) && "No info to read function later?");
+
+ // Just forget the function body, we can remat it later.
+ F->deleteBody();
+}
+
+
+Module *BitcodeReader::materializeModule(std::string *ErrInfo) {
+ // Iterate over the module, deserializing any functions that are still on
+ // disk.
+ for (Module::iterator F = TheModule->begin(), E = TheModule->end();
+ F != E; ++F)
+ if (F->isMaterializable() &&
+ Materialize(F, ErrInfo))
+ return 0;
+
+ // Upgrade any intrinsic calls that slipped through (should not happen!) and
+ // delete the old functions to clean up. We can't do this unless the entire
+ // module is materialized because there could always be another function body
+ // with calls to the old function.
+ for (std::vector<std::pair<Function*, Function*> >::iterator I =
+ UpgradedIntrinsics.begin(), E = UpgradedIntrinsics.end(); I != E; ++I) {
+ if (I->first != I->second) {
+ for (Value::use_iterator UI = I->first->use_begin(),
+ UE = I->first->use_end(); UI != UE; ) {
+ if (CallInst* CI = dyn_cast<CallInst>(*UI++))
+ UpgradeIntrinsicCall(CI, I->second);
+ }
+ if (!I->first->use_empty())
+ I->first->replaceAllUsesWith(I->second);
+ I->first->eraseFromParent();
+ }
+ }
+ std::vector<std::pair<Function*, Function*> >().swap(UpgradedIntrinsics);
+
+ // Check debug info intrinsics.
+ CheckDebugInfoIntrinsics(TheModule);
+
+ return false;
+}
+
+
+/// This method is provided by the parent ModuleProvde class and overriden
+/// here. It simply releases the module from its provided and frees up our
+/// state.
+/// @brief Release our hold on the generated module
+Module *BitcodeReader::releaseModule(std::string *ErrInfo) {
+ // Since we're losing control of this Module, we must hand it back complete
+ Module *M = ModuleProvider::releaseModule(ErrInfo);
+ FreeState();
+ return M;
+}
+
+
+//===----------------------------------------------------------------------===//
// External interface
//===----------------------------------------------------------------------===//
+/// getBitcodeModuleProvider - lazy function-at-a-time loading from a file.
+///
+ModuleProvider *llvm::getBitcodeModuleProvider(MemoryBuffer *Buffer,
+ LLVMContext& Context,
+ std::string *ErrMsg) {
+ BitcodeReader *R = new BitcodeReader(Buffer, Context);
+ if (R->ParseBitcodeInto(0)) {
+ if (ErrMsg)
+ *ErrMsg = R->getErrorString();
+
+ // Don't let the BitcodeReader dtor delete 'Buffer'.
+ R->releaseMemoryBuffer();
+ delete R;
+ return 0;
+ }
+ return R;
+}
+
/// getLazyBitcodeModule - lazy function-at-a-time loading from a file.
///
Module *llvm::getLazyBitcodeModule(MemoryBuffer *Buffer,
Modified: llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.h?rev=98641&r1=98640&r2=98641&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.h (original)
+++ llvm/branches/Apple/Morbo/lib/Bitcode/Reader/BitcodeReader.h Tue Mar 16 12:06:03 2010
@@ -14,6 +14,7 @@
#ifndef BITCODE_READER_H
#define BITCODE_READER_H
+#include "llvm/ModuleProvider.h"
#include "llvm/GVMaterializer.h"
#include "llvm/Attributes.h"
#include "llvm/Type.h"
@@ -121,9 +122,8 @@
void AssignValue(Value *V, unsigned Idx);
};
-class BitcodeReader : public GVMaterializer {
+class BitcodeReader : public GVMaterializer, public ModuleProvider {
LLVMContext &Context;
- Module *TheModule;
MemoryBuffer *Buffer;
bool BufferOwned;
BitstreamReader StreamFile;
@@ -173,7 +173,7 @@
public:
explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext &C)
- : Context(C), TheModule(0), Buffer(buffer), BufferOwned(false),
+ : Context(C), Buffer(buffer), BufferOwned(false),
ErrorString(0), ValueList(C), MDValueList(C) {
HasReversedFunctionsWithBodies = false;
}
@@ -183,10 +183,22 @@
void FreeState();
+ /// releaseMemoryBuffer - This causes the reader to completely forget about
+ /// the memory buffer it contains, which prevents the buffer from being
+ /// destroyed when it is deleted.
+ void releaseMemoryBuffer() {
+ Buffer = 0;
+ }
+
/// setBufferOwned - If this is true, the reader will destroy the MemoryBuffer
/// when the reader is destroyed.
void setBufferOwned(bool Owned) { BufferOwned = Owned; }
+ virtual bool materializeFunction(Function *F, std::string *ErrInfo = 0);
+ virtual Module *materializeModule(std::string *ErrInfo = 0);
+ virtual void dematerializeFunction(Function *F);
+ virtual Module *releaseModule(std::string *ErrInfo = 0);
+
virtual bool isMaterializable(const GlobalValue *GV) const;
virtual bool isDematerializable(const GlobalValue *GV) const;
virtual bool Materialize(GlobalValue *GV, std::string *ErrInfo = 0);
Modified: llvm/branches/Apple/Morbo/lib/ExecutionEngine/ExecutionEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/ExecutionEngine/ExecutionEngine.cpp?rev=98641&r1=98640&r2=98641&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/ExecutionEngine/ExecutionEngine.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/ExecutionEngine/ExecutionEngine.cpp Tue Mar 16 12:06:03 2010
@@ -18,6 +18,7 @@
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
+#include "llvm/ModuleProvider.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Debug.h"
@@ -72,6 +73,23 @@
return new char[GVSize];
}
+/// removeModuleProvider - Remove a ModuleProvider from the list of modules.
+/// Relases the Module from the ModuleProvider, materializing it in the
+/// process, and returns the materialized Module.
+Module* ExecutionEngine::removeModuleProvider(ModuleProvider *P,
+ std::string *ErrInfo) {
+ for(SmallVector<Module *, 1>::iterator I = Modules.begin(),
+ E = Modules.end(); I != E; ++I) {
+ Module *Found = *I;
+ if (Found == P->getModule()) {
+ Modules.erase(I);
+ clearGlobalMappingsFromModule(P->getModule());
+ return P->getModule();
+ }
+ }
+ return NULL;
+}
+
/// removeModule - Remove a Module from the list of modules.
bool ExecutionEngine::removeModule(Module *M) {
for(SmallVector<Module *, 1>::iterator I = Modules.begin(),
Modified: llvm/branches/Apple/Morbo/lib/ExecutionEngine/JIT/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/ExecutionEngine/JIT/JIT.cpp?rev=98641&r1=98640&r2=98641&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/ExecutionEngine/JIT/JIT.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/ExecutionEngine/JIT/JIT.cpp Tue Mar 16 12:06:03 2010
@@ -19,6 +19,7 @@
#include "llvm/GlobalVariable.h"
#include "llvm/Instructions.h"
#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ModuleProvider.h"
#include "llvm/CodeGen/JITCodeEmitter.h"
#include "llvm/CodeGen/MachineCodeInfo.h"
#include "llvm/ExecutionEngine/GenericValue.h"
@@ -192,6 +193,15 @@
#endif // __APPLE__
#endif // __GNUC__
+ExecutionEngine *ExecutionEngine::createJIT(ModuleProvider *MP,
+ std::string *ErrorStr,
+ JITMemoryManager *JMM,
+ CodeGenOpt::Level OptLevel,
+ bool GVsWithCode,
+ CodeModel::Model CMM) {
+ return createJIT(MP->getModule(), ErrorStr, JMM, OptLevel, GVsWithCode, CMM);
+}
+
/// createJIT - This is the factory method for creating a JIT for the current
/// machine, it does not fall back to the interpreter. This takes ownership
/// of the module.
Copied: llvm/branches/Apple/Morbo/lib/VMCore/ModuleProvider.cpp (from r96832, llvm/branches/Apple/Hermes/lib/VMCore/ModuleProvider.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/VMCore/ModuleProvider.cpp?p2=llvm/branches/Apple/Morbo/lib/VMCore/ModuleProvider.cpp&p1=llvm/branches/Apple/Hermes/lib/VMCore/ModuleProvider.cpp&r1=96832&r2=98641&rev=98641&view=diff
==============================================================================
--- llvm/branches/Apple/Hermes/lib/VMCore/ModuleProvider.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/VMCore/ModuleProvider.cpp Tue Mar 16 12:06:03 2010
@@ -20,7 +20,7 @@
ModuleProvider::ModuleProvider() : TheModule(0) { }
/// dtor - when we leave, we take our Module with us
-///
+/// NOTE: Not in this version. ModuleProvider is here to provide JIT backward
+/// compatibility. ExecutionEngine is manually deleting the modules.
ModuleProvider::~ModuleProvider() {
- delete TheModule;
}
Modified: llvm/branches/Apple/Morbo/lib/VMCore/PassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/VMCore/PassManager.cpp?rev=98641&r1=98640&r2=98641&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/VMCore/PassManager.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/VMCore/PassManager.cpp Tue Mar 16 12:06:03 2010
@@ -18,6 +18,7 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/Timer.h"
#include "llvm/Module.h"
+#include "llvm/ModuleProvider.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/raw_ostream.h"
@@ -1204,6 +1205,15 @@
FPM->setResolver(AR);
}
+FunctionPassManager::FunctionPassManager(ModuleProvider *P) : M(P->getModule()){
+ FPM = new FunctionPassManagerImpl(0);
+ // FPM is the top level manager.
+ FPM->setTopLevelManager(FPM);
+
+ AnalysisResolver *AR = new AnalysisResolver(*FPM);
+ FPM->setResolver(AR);
+}
+
FunctionPassManager::~FunctionPassManager() {
delete FPM;
}
Modified: llvm/branches/Apple/Morbo/tools/lli/lli.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/tools/lli/lli.cpp?rev=98641&r1=98640&r2=98641&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/tools/lli/lli.cpp (original)
+++ llvm/branches/Apple/Morbo/tools/lli/lli.cpp Tue Mar 16 12:06:03 2010
@@ -15,6 +15,7 @@
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
+#include "llvm/ModuleProvider.h"
#include "llvm/Type.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/CodeGen/LinkAllCodegenComponents.h"
@@ -125,28 +126,28 @@
// Load the bitcode...
std::string ErrorMsg;
- Module *Mod = NULL;
+ ModuleProvider *MP = NULL;
if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile,&ErrorMsg)){
- Mod = getLazyBitcodeModule(Buffer, Context, &ErrorMsg);
- if (!Mod) delete Buffer;
+ MP = getBitcodeModuleProvider(Buffer, Context, &ErrorMsg);
+ if (!MP) delete Buffer;
}
- if (!Mod) {
+ if (!MP) {
errs() << argv[0] << ": error loading program '" << InputFile << "': "
<< ErrorMsg << "\n";
exit(1);
}
- // If not jitting lazily, load the whole bitcode file eagerly too.
- if (NoLazyCompilation) {
- if (Mod->MaterializeAllPermanently(&ErrorMsg)) {
- errs() << argv[0] << ": bitcode didn't read correctly.\n";
- errs() << "Reason: " << ErrorMsg << "\n";
- exit(1);
- }
+ // Get the module as the MP could go away once EE takes over.
+ Module *Mod = NoLazyCompilation
+ ? MP->materializeModule(&ErrorMsg) : MP->getModule();
+ if (!Mod) {
+ errs() << argv[0] << ": bitcode didn't read correctly.\n";
+ errs() << "Reason: " << ErrorMsg << "\n";
+ exit(1);
}
- EngineBuilder builder(Mod);
+ EngineBuilder builder(MP);
builder.setMArch(MArch);
builder.setMCPU(MCPU);
builder.setMAttrs(MAttrs);
More information about the llvm-branch-commits
mailing list