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

Dominik Adamski via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 20 05:10:46 PDT 2023


================
@@ -1173,13 +1365,29 @@ 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 = TIDAddrAlloca;
+  Instruction *ZeroAddr = ZeroAddrAlloca;
+  if (ArgsInZeroAddressSpace && M.getDataLayout().getAllocaAddrSpace() != 0) {
+    // Add additional casts to enforce pointers in zero address spac
+    TIDAddr = new AddrSpaceCastInst(TIDAddrAlloca,
----------------
DominikAdamski wrote:

Builder.CreateAddrSpaceCast returns pointer to  llvm::Value. If we replace `new AddrSpaceCastInst` by Builder call, then we need to perform cast to Instruction, to store created item in ToBeDeleted. We cannot modify ToBeDeleted, because we need to  invoke "eraseFromParent" to delete instruction.

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


More information about the llvm-commits mailing list