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

Akash Banerjee via flang-commits flang-commits at lists.llvm.org
Wed Nov 15 15:18:26 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) {
----------------
TIFitis wrote:

Given that these values are explicitly coming from the BoxValue bounds, I'm not expecting them to have more than one result.

I'll add an assert for this perhaps.

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


More information about the flang-commits mailing list