================ @@ -594,45 +594,85 @@ convertOmpOrderedRegion(Operation &opInst, llvm::IRBuilderBase &builder, /// Allocate space for privatized reduction variables. template <typename T> -static void allocByValReductionVars( - T loop, ArrayRef<BlockArgument> reductionArgs, llvm::IRBuilderBase &builder, - LLVM::ModuleTranslation &moduleTranslation, - llvm::OpenMPIRBuilder::InsertPointTy &allocaIP, - SmallVectorImpl<omp::DeclareReductionOp> &reductionDecls, - SmallVectorImpl<llvm::Value *> &privateReductionVariables, - DenseMap<Value, llvm::Value *> &reductionVariableMap, - llvm::ArrayRef<bool> isByRefs) { +static LogicalResult +allocReductionVars(T loop, ArrayRef<BlockArgument> reductionArgs, + llvm::IRBuilderBase &builder, + LLVM::ModuleTranslation &moduleTranslation, + llvm::OpenMPIRBuilder::InsertPointTy &allocaIP, + SmallVectorImpl<omp::DeclareReductionOp> &reductionDecls, + SmallVectorImpl<llvm::Value *> &privateReductionVariables, + DenseMap<Value, llvm::Value *> &reductionVariableMap, + llvm::ArrayRef<bool> isByRefs) { llvm::IRBuilderBase::InsertPointGuard guard(builder); builder.SetInsertPoint(allocaIP.getBlock()->getTerminator()); + // delay creating stores until after all allocas + SmallVector<std::pair<llvm::Value *, llvm::Value *>> storesToCreate; + storesToCreate.reserve(loop.getNumReductionVars()); + for (std::size_t i = 0; i < loop.getNumReductionVars(); ++i) { - if (isByRefs[i]) - continue; - llvm::Value *var = builder.CreateAlloca( - moduleTranslation.convertType(reductionDecls[i].getType())); - moduleTranslation.mapValue(reductionArgs[i], var); - privateReductionVariables[i] = var; - reductionVariableMap.try_emplace(loop.getReductionVars()[i], var); + Region &allocRegion = reductionDecls[i].getAllocRegion(); + if (isByRefs[i]) { + if (allocRegion.empty()) ---------------- Leporacanthicus wrote:
What does allocRegion empty mean here? It's not been created? If so, where does the alloca go? https://github.com/llvm/llvm-project/pull/102524 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits