diff --git a/flang/tools/tco/tco.cpp b/flang/tools/tco/tco.cpp --- a/flang/tools/tco/tco.cpp +++ b/flang/tools/tco/tco.cpp @@ -47,14 +47,15 @@ } // compile a .fir file -static int compileFIR() { +static mlir::LogicalResult +compileFIR(const mlir::PassPipelineCLParser &passPipeline) { // check that there is a file to load ErrorOr> fileOrErr = MemoryBuffer::getFileOrSTDIN(inputFilename); if (std::error_code EC = fileOrErr.getError()) { errs() << "Could not open file: " << EC.message() << '\n'; - return 1; + return mlir::failure(); } // load the file into a module @@ -66,11 +67,11 @@ if (!owningRef) { errs() << "Error can't load file " << inputFilename << '\n'; - return 2; + return mlir::failure(); } if (mlir::failed(owningRef->verify())) { errs() << "Error verifying FIR module\n"; - return 4; + return mlir::failure(); } std::error_code ec; @@ -94,13 +95,13 @@ if (emitFir) printModuleBody(*owningRef, out.os()); out.keep(); - return 0; + return mlir::success(); } // pass manager failed printModuleBody(*owningRef, errs()); errs() << "\n\nFAILED: " << inputFilename << '\n'; - return 8; + return mlir::failure(); } int main(int argc, char **argv) { @@ -109,5 +110,5 @@ mlir::registerPassManagerCLOptions(); mlir::PassPipelineCLParser passPipe("", "Compiler passes to run"); cl::ParseCommandLineOptions(argc, argv, "Tilikum Crossing Optimizer\n"); - return compileFIR(); + return mlir::failed(compileFIR(passPipe)); }