================ @@ -1698,6 +1701,64 @@ void OpenMPIRBuilder::createTaskyield(const LocationDescription &Loc) { emitTaskyieldImpl(Loc); } +// Processes the dependencies in Dependencies and does the following +// - Allocates space on the stack of an array of DependInfo objects +// - Populates each DependInfo object with relevant information of +// the corresponding dependence. +// - All code is inserted in the entry block of the current function. +static Value * +emitDepArray(OpenMPIRBuilder &OMPBuilder, + SmallVector<OpenMPIRBuilder::DependData> &Dependencies) { + // Early return if we have no dependencies to process + if (!Dependencies.size()) + return nullptr; + + IRBuilderBase &Builder = OMPBuilder.Builder; + Type *DependInfo = OMPBuilder.DependInfo; + Module &M = OMPBuilder.M; + + Value *DepArray = nullptr; + if (Dependencies.size()) { + OpenMPIRBuilder::InsertPointTy OldIP = Builder.saveIP(); + Builder.SetInsertPoint( + &OldIP.getBlock()->getParent()->getEntryBlock().back()); + + Type *DepArrayTy = ArrayType::get(DependInfo, Dependencies.size()); + DepArray = Builder.CreateAlloca(DepArrayTy, nullptr, ".dep.arr.addr"); + + unsigned P = 0; + for (const OpenMPIRBuilder::DependData &Dep : Dependencies) { + Value *Base = + Builder.CreateConstInBoundsGEP2_64(DepArrayTy, DepArray, 0, P); + // Store the pointer to the variable + Value *Addr = Builder.CreateStructGEP( + DependInfo, Base, + static_cast<unsigned int>(RTLDependInfoFields::BaseAddr)); + Value *DepValPtr = + Builder.CreatePtrToInt(Dep.DepVal, Builder.getInt64Ty()); + Builder.CreateStore(DepValPtr, Addr); + // Store the size of the variable + Value *Size = Builder.CreateStructGEP( + DependInfo, Base, + static_cast<unsigned int>(RTLDependInfoFields::Len)); + Builder.CreateStore(Builder.getInt64(M.getDataLayout().getTypeStoreSize( + Dep.DepValueType)), + Size); + // Store the dependency kind + Value *Flags = Builder.CreateStructGEP( + DependInfo, Base, + static_cast<unsigned int>(RTLDependInfoFields::Flags)); + Builder.CreateStore( + ConstantInt::get(Builder.getInt8Ty(), + static_cast<unsigned int>(Dep.DepKind)), + Flags); ---------------- Meinersbur wrote:
Consider adding a comment with a mock source of what is generate here: ``` DepArray[P].BaseAddre = ... ``` https://github.com/llvm/llvm-project/pull/93977 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits