[Mlir-commits] [openmp] [mlir] [flang] [Flang][OpenMP] Remove use of non reference values from MapInfoOp (PR #72444)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Nov 15 15:13:56 PST 2023


================
@@ -2549,6 +2546,43 @@ static void genBodyOfTargetOp(
     argIndex++;
   }
 
+  // Check if cloning the bounds introduced any dependency on the outer region.
+  // If so, then either clone them as well if trivial, or else add them to the
+  // map and block_argument lists.
+  llvm::SetVector<mlir::Value> valuesDefinedAbove;
+  mlir::getUsedValuesDefinedAbove(region, valuesDefinedAbove);
+  while (!valuesDefinedAbove.empty()) {
+    for (mlir::Value val : valuesDefinedAbove) {
+      if (fir::isa_trivial(val.getType())) {
+        mlir::Operation *clonedVal = val.getDefiningOp()->clone();
+        regionBlock->push_front(clonedVal);
+        val.replaceUsesWithIf(
+            clonedVal->getResult(0), [regionBlock](mlir::OpOperand &use) {
----------------
agozillon wrote:

Is it possible for a trivial value to have more than one result? I'm wondering if we need to cover the scenario where we have something with multiple returns, but that can probably come in a future patch if we ever do run into it I imagine and isn't necessary for now. 

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


More information about the Mlir-commits mailing list