16
16
17
17
#include " mlir/Pass/Pass.h"
18
18
#include " mlir/Pass/PassManager.h"
19
+ #include " mlir/Support/LogicalResult.h"
19
20
20
21
namespace cir {
21
22
mlir::LogicalResult
@@ -29,9 +30,15 @@ runCIRToCIRPasses(mlir::ModuleOp theModule, mlir::MLIRContext *mlirCtx,
29
30
mlir::PassManager pm (mlirCtx);
30
31
pm.addPass (mlir::createMergeCleanupsPass ());
31
32
33
+ // TODO(CIR): Make this actually propagate errors correctly. This is stubbed
34
+ // in to get rebases going.
35
+ auto errorHandler = [](const llvm::Twine &) -> mlir::LogicalResult {
36
+ return mlir::LogicalResult::failure ();
37
+ };
38
+
32
39
if (enableLifetime) {
33
40
auto lifetimePass = mlir::createLifetimeCheckPass (&astCtx);
34
- if (lifetimePass->initializeOptions (lifetimeOpts).failed ()) {
41
+ if (lifetimePass->initializeOptions (lifetimeOpts, errorHandler ).failed ()) {
35
42
passOptParsingFailure = lifetimeOpts;
36
43
return mlir::failure ();
37
44
}
@@ -40,7 +47,8 @@ runCIRToCIRPasses(mlir::ModuleOp theModule, mlir::MLIRContext *mlirCtx,
40
47
41
48
if (enableIdiomRecognizer) {
42
49
auto idiomPass = mlir::createIdiomRecognizerPass (&astCtx);
43
- if (idiomPass->initializeOptions (idiomRecognizerOpts).failed ()) {
50
+ if (idiomPass->initializeOptions (idiomRecognizerOpts, errorHandler)
51
+ .failed ()) {
44
52
passOptParsingFailure = idiomRecognizerOpts;
45
53
return mlir::failure ();
46
54
}
@@ -49,7 +57,7 @@ runCIRToCIRPasses(mlir::ModuleOp theModule, mlir::MLIRContext *mlirCtx,
49
57
50
58
if (enableLibOpt) {
51
59
auto libOpPass = mlir::createLibOptPass (&astCtx);
52
- if (libOpPass->initializeOptions (libOptOpts).failed ()) {
60
+ if (libOpPass->initializeOptions (libOptOpts, errorHandler ).failed ()) {
53
61
passOptParsingFailure = libOptOpts;
54
62
return mlir::failure ();
55
63
}
@@ -77,4 +85,4 @@ void populateCIRPreLoweringPasses(OpPassManager &pm) {
77
85
// add other passes here
78
86
}
79
87
80
- } // namespace mlir
88
+ } // namespace mlir
0 commit comments