X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Flli%2Flli.cpp;h=13472214dfbd5303e5d6804e353b7975c27ec56f;hb=875710a2fd6b3c4f814961582594bd5c1cdb493a;hp=7bbc5dc97bfc4864f4e50ac3b98cb0f834cc5249;hpb=1a6eca243f9274b9b371b7306fa939568ce5c37f;p=oota-llvm.git diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index 7bbc5dc97bf..13472214dfb 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -13,7 +13,6 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "lli" #include "llvm/IR/LLVMContext.h" #include "RemoteMemoryManager.h" #include "RemoteTarget.h" @@ -23,7 +22,6 @@ #include "llvm/CodeGen/LinkAllCodegenComponents.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/ExecutionEngine/Interpreter.h" -#include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/JITEventListener.h" #include "llvm/ExecutionEngine/JITMemoryManager.h" #include "llvm/ExecutionEngine/MCJIT.h" @@ -64,6 +62,8 @@ using namespace llvm; +#define DEBUG_TYPE "lli" + namespace { cl::opt InputFile(cl::desc(""), cl::Positional, cl::init("-")); @@ -75,10 +75,6 @@ namespace { cl::desc("Force interpretation: disable JIT"), cl::init(false)); - cl::opt UseMCJIT( - "use-mcjit", cl::desc("Enable use of the MC-based JIT (if available)"), - cl::init(false)); - cl::opt DebugIR( "debug-ir", cl::desc("Generate debug information to allow debugging IR."), cl::init(false)); @@ -262,7 +258,7 @@ public: } virtual ~LLIObjectCache() {} - virtual void notifyObjectCompiled(const Module *M, const MemoryBuffer *Obj) { + void notifyObjectCompiled(const Module *M, const MemoryBuffer *Obj) override { const std::string ModuleID = M->getModuleIdentifier(); std::string CacheName; if (!getCacheFilename(ModuleID, CacheName)) @@ -278,22 +274,22 @@ public: outfile.close(); } - virtual MemoryBuffer* getObject(const Module* M) { + MemoryBuffer* getObject(const Module* M) override { const std::string ModuleID = M->getModuleIdentifier(); std::string CacheName; if (!getCacheFilename(ModuleID, CacheName)) - return NULL; + return nullptr; // Load the object from the cache filename - OwningPtr IRObjectBuffer; - MemoryBuffer::getFile(CacheName.c_str(), IRObjectBuffer, -1, false); + ErrorOr> IRObjectBuffer = + MemoryBuffer::getFile(CacheName.c_str(), -1, false); // If the file isn't there, that's OK. if (!IRObjectBuffer) - return NULL; + return nullptr; // MCJIT will want to write into this buffer, and we don't want that // because the file has probably just been mmapped. Instead we make // a copy. The filed-based buffer will be released when it goes // out of scope. - return MemoryBuffer::getMemBufferCopy(IRObjectBuffer->getBuffer()); + return MemoryBuffer::getMemBufferCopy(IRObjectBuffer.get()->getBuffer()); } private: @@ -319,8 +315,8 @@ private: } }; -static ExecutionEngine *EE = 0; -static LLIObjectCache *CacheManager = 0; +static ExecutionEngine *EE = nullptr; +static LLIObjectCache *CacheManager = nullptr; static void do_shutdown() { // Cygwin-1.5 invokes DLL's dtors before atexit handler. @@ -404,17 +400,14 @@ int main(int argc, char **argv, char * const *envp) { } if (EnableCacheManager) { - if (UseMCJIT) { - std::string CacheName("file:"); - CacheName.append(InputFile); - Mod->setModuleIdentifier(CacheName); - } else - errs() << "warning: -enable-cache-manager can only be used with MCJIT."; + std::string CacheName("file:"); + CacheName.append(InputFile); + Mod->setModuleIdentifier(CacheName); } // If not jitting lazily, load the whole bitcode file eagerly too. if (NoLazyCompilation) { - if (error_code EC = Mod->materializeAllPermanently()) { + if (std::error_code EC = Mod->materializeAllPermanently()) { errs() << argv[0] << ": bitcode didn't read correctly.\n"; errs() << "Reason: " << EC.message() << "\n"; exit(1); @@ -422,12 +415,6 @@ int main(int argc, char **argv, char * const *envp) { } if (DebugIR) { - if (!UseMCJIT) { - errs() << "warning: -debug-ir used without -use-mcjit. Only partial debug" - << " information will be emitted by the non-MC JIT engine. To see full" - << " source debug information, enable the flag '-use-mcjit'.\n"; - - } ModulePass *DebugIRPass = createDebugIRPass(); DebugIRPass->runOnModule(*Mod); } @@ -449,9 +436,8 @@ int main(int argc, char **argv, char * const *envp) { Mod->setTargetTriple(Triple::normalize(TargetTriple)); // Enable MCJIT if desired. - RTDyldMemoryManager *RTDyldMM = 0; - if (UseMCJIT && !ForceInterpreter) { - builder.setUseMCJIT(true); + RTDyldMemoryManager *RTDyldMM = nullptr; + if (!ForceInterpreter) { if (RemoteMCJIT) RTDyldMM = new RemoteMemoryManager(); else @@ -462,7 +448,7 @@ int main(int argc, char **argv, char * const *envp) { errs() << "error: Remote process execution requires -use-mcjit\n"; exit(1); } - builder.setJITMemoryManager(ForceInterpreter ? 0 : + builder.setJITMemoryManager(ForceInterpreter ? nullptr : JITMemoryManager::CreateDefaultMemManager()); } @@ -516,40 +502,38 @@ int main(int argc, char **argv, char * const *envp) { return 1; } if (EnableCacheManager) { - if (UseMCJIT) { - std::string CacheName("file:"); - CacheName.append(ExtraModules[i]); - XMod->setModuleIdentifier(CacheName); - } - // else, we already printed a warning above. + std::string CacheName("file:"); + CacheName.append(ExtraModules[i]); + XMod->setModuleIdentifier(CacheName); } EE->addModule(XMod); } for (unsigned i = 0, e = ExtraObjects.size(); i != e; ++i) { - ErrorOr Obj = + ErrorOr> Obj = object::ObjectFile::createObjectFile(ExtraObjects[i]); if (!Obj) { Err.print(argv[0], errs()); return 1; } - EE->addObjectFile(Obj.get()); + EE->addObjectFile(std::move(Obj.get())); } for (unsigned i = 0, e = ExtraArchives.size(); i != e; ++i) { - OwningPtr ArBuf; - error_code ec; - ec = MemoryBuffer::getFileOrSTDIN(ExtraArchives[i], ArBuf); - if (ec) { + ErrorOr> ArBuf = + MemoryBuffer::getFileOrSTDIN(ExtraArchives[i]); + if (!ArBuf) { Err.print(argv[0], errs()); return 1; } - object::Archive *Ar = new object::Archive(ArBuf.release(), ec); - if (ec || !Ar) { - Err.print(argv[0], errs()); + + ErrorOr> ArOrErr = + object::Archive::create(std::move(ArBuf.get())); + if (std::error_code EC = ArOrErr.getError()) { + errs() << EC.message(); return 1; } - EE->addArchive(Ar); + EE->addArchive(std::move(ArOrErr.get())); } // If the target is Cygwin/MingW and we are generating remote code, we @@ -609,20 +593,12 @@ int main(int argc, char **argv, char * const *envp) { NULL); // Run static constructors. - if (UseMCJIT && !ForceInterpreter) { + if (!ForceInterpreter) { // Give MCJIT a chance to apply relocations and set page permissions. EE->finalizeObject(); } EE->runStaticConstructorsDestructors(false); - if (!UseMCJIT && NoLazyCompilation) { - for (Module::iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) { - Function *Fn = &*I; - if (Fn != EntryFn && !Fn->isDeclaration()) - EE->getPointerToFunction(Fn); - } - } - // Trigger compilation separately so code regions that need to be // invalidated will be known. (void)EE->getPointerToFunction(EntryFn); @@ -662,7 +638,7 @@ int main(int argc, char **argv, char * const *envp) { // address space, assign the section addresses to resolve any relocations, // and send it to the target. - OwningPtr Target; + std::unique_ptr Target; if (!ChildExecPath.empty()) { // Remote execution on a child process #ifndef LLVM_ON_UNIX // FIXME: Remove this pointless fallback mode which causes tests to "pass"