[Mlir-commits] [mlir] b24de9f - [mlir] ExecutionEngine: default enableObjectCache to false

Emilio Cota llvmlistbot at llvm.org
Thu Mar 10 08:25:09 PST 2022


Author: Emilio Cota
Date: 2022-03-10T11:24:48-05:00
New Revision: b24de9f6845217f03014a36814d61f4ed91f0405

URL: https://github.com/llvm/llvm-project/commit/b24de9f6845217f03014a36814d61f4ed91f0405
DIFF: https://github.com/llvm/llvm-project/commit/b24de9f6845217f03014a36814d61f4ed91f0405.diff

LOG: [mlir] ExecutionEngine: default enableObjectCache to false

The enableObjectCache option was added in
https://reviews.llvm.org/rG06e8101034e, defaulting to false. However,
the init code added there got its logic reversed
(cache(enableObjectCache ? nullptr : new SimpleObjectCache()), which was
fixed in https://reviews.llvm.org/rGd1186fcb04 by setting the default to
true, thereby preserving the existing behavior even if it was
unintentional.

Default now the object cache to false as it was originally intended.
While at it, mention in enableObjectCache's documentation how the
cache can be dumped.

Reviewed-by: mehdi_amini
Differential Revision: https://reviews.llvm.org/D121291

Added: 
    

Modified: 
    mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
    mlir/lib/ExecutionEngine/ExecutionEngine.cpp
    mlir/lib/ExecutionEngine/JitRunner.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
index 34fd7f21751ac..2b5cd2a8e9659 100644
--- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
+++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
@@ -75,8 +75,9 @@ struct ExecutionEngineOptions {
   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
index 916d764a75dad..210e52c8797ff 100644
--- a/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -97,6 +97,11 @@ void SimpleObjectCache::dumpToObjectFile(StringRef outputFilename) {
 }
 
 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
index 40c5ac81e42be..fcab951c51497 100644
--- a/mlir/lib/ExecutionEngine/JitRunner.cpp
+++ b/mlir/lib/ExecutionEngine/JitRunner.cpp
@@ -212,6 +212,7 @@ static Error compileAndExecute(Options &options, ModuleOp module,
   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();


        


More information about the Mlir-commits mailing list