Skip to content

Commit bca0619

Browse files
committed
[flang] Adapt mlir based error status handling in tco tool
Earlier scheme was using negative integers for communicating error status, switch to canonical MLIR style. f18 commit authored by @schweitz: flang-compiler@c1af08d Reviewed By: mehdi_amini, clementval, svedanayagam Differential Revision: https://reviews.llvm.org/D96068
1 parent fb74e1e commit bca0619

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

flang/tools/tco/tco.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ static void printModuleBody(mlir::ModuleOp mod, raw_ostream &output) {
4747
}
4848

4949
// compile a .fir file
50-
static int compileFIR() {
50+
static mlir::LogicalResult
51+
compileFIR(const mlir::PassPipelineCLParser &passPipeline) {
5152
// check that there is a file to load
5253
ErrorOr<std::unique_ptr<MemoryBuffer>> fileOrErr =
5354
MemoryBuffer::getFileOrSTDIN(inputFilename);
5455

5556
if (std::error_code EC = fileOrErr.getError()) {
5657
errs() << "Could not open file: " << EC.message() << '\n';
57-
return 1;
58+
return mlir::failure();
5859
}
5960

6061
// load the file into a module
@@ -66,11 +67,11 @@ static int compileFIR() {
6667

6768
if (!owningRef) {
6869
errs() << "Error can't load file " << inputFilename << '\n';
69-
return 2;
70+
return mlir::failure();
7071
}
7172
if (mlir::failed(owningRef->verify())) {
7273
errs() << "Error verifying FIR module\n";
73-
return 4;
74+
return mlir::failure();
7475
}
7576

7677
std::error_code ec;
@@ -94,13 +95,13 @@ static int compileFIR() {
9495
if (emitFir)
9596
printModuleBody(*owningRef, out.os());
9697
out.keep();
97-
return 0;
98+
return mlir::success();
9899
}
99100

100101
// pass manager failed
101102
printModuleBody(*owningRef, errs());
102103
errs() << "\n\nFAILED: " << inputFilename << '\n';
103-
return 8;
104+
return mlir::failure();
104105
}
105106

106107
int main(int argc, char **argv) {
@@ -109,5 +110,5 @@ int main(int argc, char **argv) {
109110
mlir::registerPassManagerCLOptions();
110111
mlir::PassPipelineCLParser passPipe("", "Compiler passes to run");
111112
cl::ParseCommandLineOptions(argc, argv, "Tilikum Crossing Optimizer\n");
112-
return compileFIR();
113+
return mlir::failed(compileFIR(passPipe));
113114
}

0 commit comments

Comments
 (0)