[Mlir-commits] [mlir] [MLIR][OpenMP] Add verifier to prevent illegal omp.critical nesting (PR #217357)

Aidan Dakhama llvmlistbot at llvm.org
Wed Aug 19 08:58:17 PDT 2026


================
@@ -4828,6 +4828,31 @@ LogicalResult CriticalDeclareOp::verify() {
   return verifySynchronizationHint(*this, getHint());
 }
 
+LogicalResult CriticalOp::verify() {
+  SymbolRefAttr currentName = getNameAttr();
+
+  CriticalOp parentCritical = (*this)->getParentOfType<CriticalOp>();
+
+  while (parentCritical) {
----------------
dakaidan wrote:

This while loop is needed because the specification forbids nesting of any depth, not just as a direct parent-child. For example, as shown in the `@nested_named_critical_indirect test`, the malformed critical region could be nested inside an `omp.single` or another operation, so we have to traverse up the ancestor chain to be sure.

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


More information about the Mlir-commits mailing list