Skip to content

Commit

Permalink
[CIR][Rebase] Stub out error handling for Pass option initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
lanza committed Apr 17, 2024
1 parent d0eed34 commit b7e1c76
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions clang/lib/CIR/CodeGen/CIRPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Support/LogicalResult.h"

namespace cir {
mlir::LogicalResult
Expand All @@ -29,9 +30,15 @@ runCIRToCIRPasses(mlir::ModuleOp theModule, mlir::MLIRContext *mlirCtx,
mlir::PassManager pm(mlirCtx);
pm.addPass(mlir::createMergeCleanupsPass());

// TODO(CIR): Make this actually propagate errors correctly. This is stubbed
// in to get rebases going.
auto errorHandler = [](const llvm::Twine &) -> mlir::LogicalResult {
return mlir::LogicalResult::failure();
};

if (enableLifetime) {
auto lifetimePass = mlir::createLifetimeCheckPass(&astCtx);
if (lifetimePass->initializeOptions(lifetimeOpts).failed()) {
if (lifetimePass->initializeOptions(lifetimeOpts, errorHandler).failed()) {
passOptParsingFailure = lifetimeOpts;
return mlir::failure();
}
Expand All @@ -40,7 +47,8 @@ runCIRToCIRPasses(mlir::ModuleOp theModule, mlir::MLIRContext *mlirCtx,

if (enableIdiomRecognizer) {
auto idiomPass = mlir::createIdiomRecognizerPass(&astCtx);
if (idiomPass->initializeOptions(idiomRecognizerOpts).failed()) {
if (idiomPass->initializeOptions(idiomRecognizerOpts, errorHandler)
.failed()) {
passOptParsingFailure = idiomRecognizerOpts;
return mlir::failure();
}
Expand All @@ -49,7 +57,7 @@ runCIRToCIRPasses(mlir::ModuleOp theModule, mlir::MLIRContext *mlirCtx,

if (enableLibOpt) {
auto libOpPass = mlir::createLibOptPass(&astCtx);
if (libOpPass->initializeOptions(libOptOpts).failed()) {
if (libOpPass->initializeOptions(libOptOpts, errorHandler).failed()) {
passOptParsingFailure = libOptOpts;
return mlir::failure();
}
Expand Down Expand Up @@ -77,4 +85,4 @@ void populateCIRPreLoweringPasses(OpPassManager &pm) {
// add other passes here
}

} // namespace mlir
} // namespace mlir

0 comments on commit b7e1c76

Please sign in to comment.