Guard copy of std::function to llvm::function_ref (fix crash)
authorMehdi Amini <joker.eph@gmail.com>
Tue, 12 Apr 2022 07:43:12 +0000 (07:43 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Tue, 12 Apr 2022 07:44:04 +0000 (07:44 +0000)
This is a footgun: assigning a null std::function to a function_ref
does not yield a null function_ref...

mlir/lib/ExecutionEngine/JitRunner.cpp

index 824d8f5..df9ec29 100644 (file)
@@ -205,7 +205,8 @@ static Error compileAndExecute(Options &options, ModuleOp module,
 
   mlir::ExecutionEngineOptions engineOptions;
   engineOptions.llvmModuleBuilder = config.llvmModuleBuilder;
-  engineOptions.transformer = config.transformer;
+  if (config.transformer)
+    engineOptions.transformer = config.transformer;
   engineOptions.jitCodeGenOptLevel = jitCodeGenOptLevel;
   engineOptions.sharedLibPaths = executionEngineLibs;
   engineOptions.enableObjectCache = true;