Assert that region is not cloned into itself.
PiperOrigin-RevId: 273707291
diff --git a/third_party/mlir/lib/IR/Region.cpp b/third_party/mlir/lib/IR/Region.cpp
index 2d9f62c..4e408f2 100644
--- a/third_party/mlir/lib/IR/Region.cpp
+++ b/third_party/mlir/lib/IR/Region.cpp
@@ -78,6 +78,7 @@
void Region::cloneInto(Region *dest, Region::iterator destPos,
BlockAndValueMapping &mapper) {
assert(dest && "expected valid region to clone into");
+ assert(this != dest && "cannot clone region into itself");
// If the list is empty there is nothing to clone.
if (empty())