[flang-commits] [flang] [OpenMP][MLIR] Add "IsolatedFromAbove" trait to omp.target (PR #67318)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Mon Oct 30 05:18:35 PDT 2023


================
@@ -2065,33 +2080,61 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
 
   auto targetOp = cast<omp::TargetOp>(opInst);
   auto &targetRegion = targetOp.getRegion();
+  DataLayout DL = DataLayout(opInst.getParentOfType<ModuleOp>());
+  SmallVector<Value> mapOperands = targetOp.getMapOperands();
+
+  // Remove mapOperands/blockArgs that have no use inside the region.
+  assert(mapOperands.size() == targetRegion.getNumArguments() &&
+         "Number of mapOperands must be same as block_arguments");
+  for (size_t i = 0; i < mapOperands.size(); i++) {
+    if (targetRegion.getArgument(i).use_empty()) {
+      targetRegion.eraseArgument(i);
+      mapOperands.erase(&mapOperands[i]);
+      i--;
+    }
+  }
----------------
kiranchandramohan wrote:

Nit: Ideally, this should be done earlier. May be the RemoveDeadValues.cpp pass can be used in the flow. No change required now.

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


More information about the flang-commits mailing list