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

via flang-commits flang-commits at lists.llvm.org
Wed Nov 15 15:22:48 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:

That's fair enough, no need to add an assert! Was more curious than anything as I've seen some of the HLFIR/FIR operations can have multiple returns

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


More information about the flang-commits mailing list