Avoid assigning to an unchecked Error.

Fixes tensorflow/mlir#97

PiperOrigin-RevId: 264743395
This commit is contained in:
River Riddle 2019-08-21 19:03:13 -07:00 committed by A. Unique TensorFlower
parent 1d10eb162c
commit 85bc8655f0
1 changed files with 14 additions and 10 deletions

View File

@ -333,16 +333,20 @@ int mlir::JitRunnerMain(
auto transformer = mlir::makeLLVMPassesTransformer(
passes, optLevel, /*targetMachine=*/tmOrError->get(), optPosition);
Error error = make_string_error("unsupported function type");
if (mainFuncType.getValue() == "f32")
error = compileAndExecuteSingleFloatReturnFunction(
m.get(), mainFuncName.getValue(), transformer);
else if (mainFuncType.getValue() == "memrefs")
error = compileAndExecuteFunctionWithMemRefs(
m.get(), mainFuncName.getValue(), transformer);
else if (mainFuncType.getValue() == "void")
error = compileAndExecuteVoidFunction(m.get(), mainFuncName.getValue(),
transformer);
// Get the function used to compile and execute the module.
using CompileAndExecuteFnT = Error (*)(
ModuleOp, StringRef, std::function<llvm::Error(llvm::Module *)>);
auto compileAndExecuteFn =
llvm::StringSwitch<CompileAndExecuteFnT>(mainFuncType.getValue())
.Case("f32", compileAndExecuteSingleFloatReturnFunction)
.Case("memrefs", compileAndExecuteFunctionWithMemRefs)
.Case("void", compileAndExecuteVoidFunction)
.Default(nullptr);
Error error =
compileAndExecuteFn
? compileAndExecuteFn(m.get(), mainFuncName.getValue(), transformer)
: make_string_error("unsupported function type");
int exitCode = EXIT_SUCCESS;
llvm::handleAllErrors(std::move(error),