mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-11 17:08:42 +00:00
[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
This commit is contained in:
parent
3e6b80b1bd
commit
fb27d542b7
@ -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));
|
||||
|
7
mlir/test/mlir-cpu-runner/verify-entry-point-result.mlir
Normal file
7
mlir/test/mlir-cpu-runner/verify-entry-point-result.mlir
Normal file
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user