1 //===-- Lower/Support/Verifier.h -- verify pass for lowering ----*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/ 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef FORTRAN_LOWER_SUPPORT_VERIFIER_H 14 #define FORTRAN_LOWER_SUPPORT_VERIFIER_H 15 16 #include "mlir/IR/Verifier.h" 17 #include "mlir/Pass/Pass.h" 18 19 namespace Fortran::lower { 20 21 /// A verification pass to verify the output from the bridge. This provides a 22 /// little bit of glue to run a verifier pass directly. 23 class VerifierPass 24 : public mlir::PassWrapper<VerifierPass, mlir::OperationPass<>> { runOnOperation()25 void runOnOperation() override final { 26 if (mlir::failed(mlir::verify(getOperation()))) 27 signalPassFailure(); 28 markAllAnalysesPreserved(); 29 } 30 }; 31 32 } // namespace Fortran::lower 33 34 #endif // FORTRAN_LOWER_SUPPORT_VERIFIER_H 35