[clang] [CIR] Add GlobalOp ctor and dtor regions (PR #160779)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 26 01:14:58 PDT 2025


================
@@ -1349,15 +1349,45 @@ mlir::LogicalResult cir::GlobalOp::verify() {
       return failure();
   }
 
+  // Verify that the constructor region, if present, has only one block which is
+  // not empty.
+  auto &ctorRegion = getCtorRegion();
+  if (!ctorRegion.empty()) {
+    if (!ctorRegion.hasOneBlock()) {
+      return emitError() << "ctor region must have exactly one block.";
+    }
+
+    auto &block = ctorRegion.front();
+    if (block.empty()) {
+      return emitError() << "ctor region shall not be empty.";
+    }
+  }
+
+  // Verify that the destructor region, if present, has only one block which is
+  // not empty.
+  auto &dtorRegion = getDtorRegion();
+  if (!dtorRegion.empty()) {
+    if (!dtorRegion.hasOneBlock()) {
+      return emitError() << "dtor region must have exactly one block.";
+    }
----------------
xlauko wrote:

No need to check after `MaxSizedRegion<1>`

https://github.com/llvm/llvm-project/pull/160779


More information about the cfe-commits mailing list