[PATCH] D146557: [MLIR][OpenMP] Added OMPIRBuilder support for use_device_ptr clause

Akash Banerjee via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 21 12:28:28 PDT 2023


TIFitis added inline comments.


================
Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4181-4191
+    for (auto &UseDeviceOp : UseDeviceInfos) {
+      auto *UseDeviceVal = UseDeviceOp.first;
+      auto &UseDeviceInfo = UseDeviceOp.second;
+      SmallDenseSet<Use *> ReplaceUses;
+      for (auto &Use : UseDeviceVal->uses()) {
+        if (UseDeviceInfo.Uses.find(&Use) == UseDeviceInfo.Uses.end())
+          ReplaceUses.insert(&Use);
----------------
I couldn't come up with a better way for the code generated inside the `target data region` to use the new `AllocaPtrs` when accessing `map operands` marked with the `use_device_ptr` clause.

Currently I am just comparing the `Users` list before and after generating the `data region` and replacing the new `uses`.

Alternative method would be to use `mlir::LLVM::moduleTranslation.mapValue` method to temporarily remap the `mlir::Value` for the `use_device_ptr` operands to the `AllocaPtrs` `llvm::Value`. But `mapValue` doesn't allow remapping of values. @kiranchandramohan Is there a good reason to prevent remapping of values?

Let me know if anyone has a better way of doing this :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146557/new/

https://reviews.llvm.org/D146557



More information about the cfe-commits mailing list