aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CIR/CodeGen/CIRGenModule.cpp
diff options
context:
space:
mode:
authorAndy Kaylor <akaylor@nvidia.com>2025-03-19 09:42:03 -0700
committerGitHub <noreply@github.com>2025-03-19 09:42:03 -0700
commit39ce99589b05ddd43e5c8b7f89ab5bbfda40d2ce (patch)
tree80a08af9b0ed4208d379867d8fe012a2d3ffc86f /clang/lib/CIR/CodeGen/CIRGenModule.cpp
parentcd26dd55959c11c1cd0ea4fe1f07e0fa9cb7a72a (diff)
downloadllvm-39ce99589b05ddd43e5c8b7f89ab5bbfda40d2ce.zip
llvm-39ce99589b05ddd43e5c8b7f89ab5bbfda40d2ce.tar.gz
llvm-39ce99589b05ddd43e5c8b7f89ab5bbfda40d2ce.tar.bz2
[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.
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp')
-rw-r--r--clang/lib/CIR/CodeGen/CIRGenModule.cpp8
1 files changed, 8 insertions, 0 deletions
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(