Add a `getUsedValuesDefinedAbove()` overload that takes an `Operation` pointer (NFC)
authorMehdi Amini <aminim@google.com>
Sun, 1 Sep 2019 23:31:40 +0000 (16:31 -0700)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Sun, 1 Sep 2019 23:32:10 +0000 (16:32 -0700)
This is a convenient utility around the existing `getUsedValuesDefinedAbove()`
that take two regions.

PiperOrigin-RevId: 266686854

mlir/include/mlir/Transforms/RegionUtils.h
mlir/lib/Transforms/Utils/RegionUtils.cpp

index a00ddc6..6316b56 100644 (file)
@@ -45,6 +45,11 @@ void replaceAllUsesInRegionWith(Value *orig, Value *replacement,
 void getUsedValuesDefinedAbove(Region &region, Region &limit,
                                llvm::SetVector<Value *> &values);
 
+/// Fill `values` with a list of values used within any of the regions provided
+/// but defined in one of the ancestors.
+void getUsedValuesDefinedAbove(llvm::MutableArrayRef<Region> regions,
+                               llvm::SetVector<Value *> &values);
+
 } // namespace mlir
 
 #endif // MLIR_TRANSFORMS_REGIONUTILS_H_
index a2b4fe3..9974e47 100644 (file)
@@ -53,3 +53,9 @@ void mlir::getUsedValuesDefinedAbove(Region &region, Region &limit,
         values.insert(operand);
   });
 }
+
+void mlir::getUsedValuesDefinedAbove(llvm::MutableArrayRef<Region> regions,
+                                     llvm::SetVector<Value *> &values) {
+  for (Region &region : regions)
+    getUsedValuesDefinedAbove(region, region, values);
+}