[Mlir-commits] [flang] [llvm] [mlir] [MLIR][OpenMP] Handle privatization for global values in MLIR->LLVM translation (PR #104407)

Kareem Ergawy llvmlistbot at llvm.org
Sun Aug 18 06:36:31 PDT 2024


================
@@ -1548,7 +1548,16 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::createParallel(
   BasicBlock *CommonExit = nullptr;
   SetVector<Value *> Inputs, Outputs, SinkingCands, HoistingCands;
   Extractor.findAllocas(CEAC, SinkingCands, HoistingCands, CommonExit);
-  Extractor.findInputsOutputs(Inputs, Outputs, SinkingCands);
+
+  Extractor.findInputsOutputs(Inputs, Outputs, SinkingCands,
+                              /*CollectGlobalInputs=*/true);
+
+  Inputs.remove_if([&](Value *I) {
+    if (auto *GV = dyn_cast_if_present<GlobalVariable>(I))
+      return GV->getValueType() == OpenMPIRBuilder::Ident;
+
+    return false;
+  });
----------------
ergawy wrote:

Tbh, I do not know if this is cleanest or best approach to solve this issue. To get a better understanding of the problem, please take a look at the new test added in `openmp-firstprivate.mlir` below as well as the 2 linked issues: https://github.com/llvm/llvm-project/issues/102939 and https://github.com/llvm/llvm-project/issues/102949.

Let me know if you disagree with the solution and/or have a better suggestion.

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


More information about the Mlir-commits mailing list