[llvm] [OpenMP][OMPIRBuilder] Add support to omp target parallel (PR #67000)

Dominik Adamski via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 9 05:35:46 PDT 2023


================
@@ -1137,13 +1318,32 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::createParallel(
   // Change the location to the outer alloca insertion point to create and
   // initialize the allocas we pass into the parallel region.
   Builder.restoreIP(OuterAllocaIP);
-  AllocaInst *TIDAddr = Builder.CreateAlloca(Int32, nullptr, "tid.addr");
-  AllocaInst *ZeroAddr = Builder.CreateAlloca(Int32, nullptr, "zero.addr");
+  AllocaInst *TIDAddrAlloca = Builder.CreateAlloca(Int32, nullptr, "tid.addr");
+  AllocaInst *ZeroAddrAlloca =
+      Builder.CreateAlloca(Int32, nullptr, "zero.addr");
+  Instruction *TIDAddr = nullptr;
+  Instruction *ZeroAddr = nullptr;
+  if (ArgsInZeroAddressSpace && M.getDataLayout().getAllocaAddrSpace() != 0) {
+    // Add additional casts to enforce pointers in zero address spac
+    TIDAddr = new AddrSpaceCastInst(TIDAddrAlloca,
+                                    TIDAddrAlloca->getType()->getPointerTo(),
+                                    "tid.addr.ascast");
+    TIDAddr->insertAfter(TIDAddrAlloca);
+    ToBeDeleted.push_back(TIDAddr);
+    ZeroAddr = new AddrSpaceCastInst(ZeroAddrAlloca,
+                                     ZeroAddrAlloca->getType()->getPointerTo(),
+                                     "zero.addr.ascast");
+    ZeroAddr->insertAfter(ZeroAddrAlloca);
+    ToBeDeleted.push_back(ZeroAddr);
+  } else {
+    TIDAddr = TIDAddrAlloca;
+    ZeroAddr = ZeroAddrAlloca;
----------------
DominikAdamski wrote:

Done

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


More information about the llvm-commits mailing list