diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h --- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h +++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h @@ -75,8 +75,9 @@ llvm::SectionMemoryManager::MemoryMapper *sectionMemoryMapper = nullptr; /// If `enableObjectCache` is set, the JIT compiler will create one to store - /// the object generated for the given module. - bool enableObjectCache = true; + /// the object generated for the given module. The contents of the cache can + /// be dumped to a file via the `dumpToObjectfile` method. + bool enableObjectCache = false; /// If enable `enableGDBNotificationListener` is set, the JIT compiler will /// notify the llvm's global GDB notification listener. diff --git a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp --- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp @@ -97,6 +97,11 @@ } void ExecutionEngine::dumpToObjectFile(StringRef filename) { + if (cache == nullptr) { + llvm::errs() << "cannot dump ExecutionEngine object code to file: " + "object cache is disabled\n"; + return; + } cache->dumpToObjectFile(filename); } diff --git a/mlir/lib/ExecutionEngine/JitRunner.cpp b/mlir/lib/ExecutionEngine/JitRunner.cpp --- a/mlir/lib/ExecutionEngine/JitRunner.cpp +++ b/mlir/lib/ExecutionEngine/JitRunner.cpp @@ -212,6 +212,7 @@ engineOptions.transformer = config.transformer; engineOptions.jitCodeGenOptLevel = jitCodeGenOptLevel; engineOptions.sharedLibPaths = executionEngineLibs; + engineOptions.enableObjectCache = true; auto expectedEngine = mlir::ExecutionEngine::create(module, engineOptions); if (!expectedEngine) return expectedEngine.takeError();