[Mlir-commits] [mlir] fb27d54 - [mlir-cpu-runner] Check entry function is void
Cullen Rhodes
llvmlistbot at llvm.org
Tue Jul 4 00:34:31 PDT 2023
Author: Cullen Rhodes
Date: 2023-07-04T07:25:16Z
New Revision: fb27d542b71920f821f9357a8ec7705a30d7b274
URL: https://github.com/llvm/llvm-project/commit/fb27d542b71920f821f9357a8ec7705a30d7b274
DIFF: https://github.com/llvm/llvm-project/commit/fb27d542b71920f821f9357a8ec7705a30d7b274.diff
LOG: [mlir-cpu-runner] Check entry function is void
Currently crashes if function isn't void when specifiying
'-entry-point-result=void'.
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D154352
Added:
mlir/test/mlir-cpu-runner/verify-entry-point-result.mlir
Modified:
mlir/lib/ExecutionEngine/JitRunner.cpp
Removed:
################################################################################
diff --git a/mlir/lib/ExecutionEngine/JitRunner.cpp b/mlir/lib/ExecutionEngine/JitRunner.cpp
index 7a02ecb8376cf1..4fbd124e928bf4 100644
--- a/mlir/lib/ExecutionEngine/JitRunner.cpp
+++ b/mlir/lib/ExecutionEngine/JitRunner.cpp
@@ -224,6 +224,12 @@ static Error compileAndExecuteVoidFunction(
SymbolTable::lookupSymbolIn(module, entryPoint));
if (!mainFunction || mainFunction.empty())
return makeStringError("entry point not found");
+
+ auto resultType = dyn_cast<LLVM::LLVMVoidType>(
+ mainFunction.getFunctionType().getReturnType());
+ if (!resultType)
+ return makeStringError("expected void function");
+
void *empty = nullptr;
return compileAndExecute(options, module, entryPoint, std::move(config),
&empty, std::move(tm));
diff --git a/mlir/test/mlir-cpu-runner/verify-entry-point-result.mlir b/mlir/test/mlir-cpu-runner/verify-entry-point-result.mlir
new file mode 100644
index 00000000000000..02db28ae4d3e09
--- /dev/null
+++ b/mlir/test/mlir-cpu-runner/verify-entry-point-result.mlir
@@ -0,0 +1,7 @@
+// RUN: not mlir-cpu-runner %s -e entry -entry-point-result=void 2>&1 | FileCheck %s
+
+// CHECK: Error: expected void function
+llvm.func @entry() -> (i32) {
+ %0 = llvm.mlir.constant(0 : index) : i32
+ llvm.return %0 : i32
+}
More information about the Mlir-commits
mailing list