[PATCH] D96068: [flang] Adapt mlir based error status handling in `tco` tool
Sourabh Singh Tomar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 4 11:31:17 PST 2021
SouraVX created this revision.
SouraVX added reviewers: schweitz, mehdi_amini, kiranktp, kiranchandramohan, clementval.
SouraVX added a project: Flang.
Herald added subscribers: rriddle, jdoerfert.
Herald added a reviewer: awarzynski.
SouraVX requested review of this revision.
Herald added subscribers: llvm-commits, stephenneuendorffer.
Herald added a project: LLVM.
Earlier scheme was using negative integers for communicating error status,
switch to canonical MLIR style.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D96068
Files:
flang/tools/tco/tco.cpp
Index: flang/tools/tco/tco.cpp
===================================================================
--- flang/tools/tco/tco.cpp
+++ 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<std::unique_ptr<MemoryBuffer>> 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));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96068.321530.patch
Type: text/x-patch
Size: 1626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210204/79d3ecf6/attachment.bin>
More information about the llvm-commits
mailing list