diff options
Diffstat (limited to 'include/llvm/ExecutionEngine/ExecutionEngine.h')
-rw-r--r-- | include/llvm/ExecutionEngine/ExecutionEngine.h | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index 4dca870..7518c1e 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -123,6 +123,9 @@ class ExecutionEngine { /// using dlsym). bool SymbolSearchingDisabled; + /// Whether the JIT should verify IR modules during compilation. + bool VerifyModules; + friend class EngineBuilder; // To allow access to JITCtor and InterpCtor. protected: @@ -181,7 +184,7 @@ public: /// freeMachineCodeForFunction works. static ExecutionEngine *create(Module *M, bool ForceInterpreter = false, - std::string *ErrorStr = 0, + std::string *ErrorStr = nullptr, CodeGenOpt::Level OptLevel = CodeGenOpt::Default, bool GVsWithCode = true); @@ -193,8 +196,8 @@ public: /// Clients should make sure to initialize targets prior to calling this /// function. static ExecutionEngine *createJIT(Module *M, - std::string *ErrorStr = 0, - JITMemoryManager *JMM = 0, + std::string *ErrorStr = nullptr, + JITMemoryManager *JMM = nullptr, CodeGenOpt::Level OptLevel = CodeGenOpt::Default, bool GVsWithCode = true, @@ -219,10 +222,7 @@ public: /// needed by another object. /// /// MCJIT will take ownership of the ObjectFile. - virtual void addObjectFile(object::ObjectFile *O) { - llvm_unreachable( - "ExecutionEngine subclass doesn't implement addObjectFile."); - } + virtual void addObjectFile(std::unique_ptr<object::ObjectFile> O); /// addArchive - Add an Archive to the execution engine. /// @@ -411,7 +411,7 @@ public: } // The JIT overrides a version that actually does this. - virtual void runJITOnFunction(Function *, MachineCodeInfo * = 0) { } + virtual void runJITOnFunction(Function *, MachineCodeInfo * = nullptr) { } /// getGlobalValueAtAddress - Return the LLVM global value object that starts /// at the specified address. @@ -478,7 +478,7 @@ public: } /// Return the target machine (if available). - virtual TargetMachine *getTargetMachine() { return NULL; } + virtual TargetMachine *getTargetMachine() { return nullptr; } /// DisableLazyCompilation - When lazy compilation is off (the default), the /// JIT will eagerly compile every function reachable from the argument to @@ -525,6 +525,17 @@ public: return SymbolSearchingDisabled; } + /// Enable/Disable IR module verification. + /// + /// Note: Module verification is enabled by default in Debug builds, and + /// disabled by default in Release. Use this method to override the default. + void setVerifyModules(bool Verify) { + VerifyModules = Verify; + } + bool getVerifyModules() const { + return VerifyModules; + } + /// InstallLazyFunctionCreator - If an unknown function is needed, the /// specified function pointer is invoked to create it. If it returns null, /// the JIT will abort. @@ -572,19 +583,28 @@ private: std::string MCPU; SmallVector<std::string, 4> MAttrs; bool UseMCJIT; + bool VerifyModules; /// InitEngine - Does the common initialization of default options. void InitEngine() { WhichEngine = EngineKind::Either; - ErrorStr = NULL; + ErrorStr = nullptr; OptLevel = CodeGenOpt::Default; - MCJMM = NULL; - JMM = NULL; + MCJMM = nullptr; + JMM = nullptr; Options = TargetOptions(); AllocateGVsWithCode = false; RelocModel = Reloc::Default; CMModel = CodeModel::JITDefault; UseMCJIT = false; + + // IR module verification is enabled by default in debug builds, and disabled + // by default in release builds. +#ifndef NDEBUG + VerifyModules = true; +#else + VerifyModules = false; +#endif } public: @@ -610,7 +630,7 @@ public: /// the setJITMemoryManager() option. EngineBuilder &setMCJITMemoryManager(RTDyldMemoryManager *mcjmm) { MCJMM = mcjmm; - JMM = NULL; + JMM = nullptr; return *this; } @@ -622,7 +642,7 @@ public: /// memory manager. This option defaults to NULL. This option overrides /// setMCJITMemoryManager() as well. EngineBuilder &setJITMemoryManager(JITMemoryManager *jmm) { - MCJMM = NULL; + MCJMM = nullptr; JMM = jmm; return *this; } @@ -694,6 +714,13 @@ public: return *this; } + /// setVerifyModules - Set whether the JIT implementation should verify + /// IR modules during compilation. + EngineBuilder &setVerifyModules(bool Verify) { + VerifyModules = Verify; + return *this; + } + /// setMAttrs - Set cpu-specific attributes. template<typename StringSequence> EngineBuilder &setMAttrs(const StringSequence &mattrs) { |