From 39ce99589b05ddd43e5c8b7f89ab5bbfda40d2ce Mon Sep 17 00:00:00 2001 From: Andy Kaylor Date: Wed, 19 Mar 2025 09:42:03 -0700 Subject: [CIR] Upstream cir-canonicalize pass (#131891) This change introduces the cir-canonicalize pass. This is a simple cir-to-cir transformation that eliminates empty scopes and redundant branches. It will be expanded in future changes to simplify other redundant instruction sequences. MLIR verification and mlir-specific command-line option handling is also introduced here. --- clang/lib/CIR/CodeGen/CIRGenModule.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp') diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index 0e3e15c..36bfc2c 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -23,6 +23,7 @@ #include "mlir/IR/BuiltinOps.h" #include "mlir/IR/Location.h" #include "mlir/IR/MLIRContext.h" +#include "mlir/IR/Verifier.h" using namespace clang; using namespace clang::CIRGen; @@ -488,6 +489,13 @@ mlir::Type CIRGenModule::convertType(QualType type) { return genTypes.convertType(type); } +bool CIRGenModule::verifyModule() const { + // Verify the module after we have finished constructing it, this will + // check the structural properties of the IR and invoke any specific + // verifiers we have on the CIR operations. + return mlir::verify(theModule).succeeded(); +} + DiagnosticBuilder CIRGenModule::errorNYI(SourceLocation loc, llvm::StringRef feature) { unsigned diagID = diags.getCustomDiagID( -- cgit v1.1