Assert that region is not cloned into itself.
authorChristian Sigg <csigg@google.com>
Wed, 9 Oct 2019 09:43:18 +0000 (02:43 -0700)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Wed, 9 Oct 2019 09:43:52 +0000 (02:43 -0700)
PiperOrigin-RevId: 273707291

mlir/lib/IR/Region.cpp

index 2d9f62c..4e408f2 100644 (file)
@@ -78,6 +78,7 @@ void Region::cloneInto(Region *dest, BlockAndValueMapping &mapper) {
 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())