================ @@ -5255,6 +5283,51 @@ convertTargetOpsInNest(Operation *op, llvm::IRBuilderBase &builder, return WalkResult::interrupt(); return WalkResult::skip(); } + + // Non-target ops might nest target-related ops, therefore, we + // translate them as non-OpenMP scopes. Translating them is needed by + // nested target-related ops since they might LLVM values defined in + // their parent non-target ops. + if (isa<omp::OpenMPDialect>(oper->getDialect()) && + oper->getParentOfType<LLVM::LLVMFuncOp>() && + !oper->getRegions().empty()) { + + // TODO Handle other ops with entry block args. + llvm::TypeSwitch<Operation &>(*oper) + .Case([&](omp::WsloopOp wsloopOp) { + forwardPrivateArgs(wsloopOp, moduleTranslation); + forwardReductionArgs(wsloopOp, moduleTranslation); + }) + .Case([&](omp::ParallelOp parallelOp) { + forwardPrivateArgs(parallelOp, moduleTranslation); + forwardReductionArgs(parallelOp, moduleTranslation); + }) + .Case([&](omp::TaskOp taskOp) { + forwardPrivateArgs(taskOp, moduleTranslation); + }); + + if (auto loopNest = dyn_cast<omp::LoopNestOp>(oper)) { + for (auto iv : loopNest.getIVs()) { + // Create fake allocas just to maintain IR validity. + moduleTranslation.mapValue( + iv, builder.CreateAlloca( + moduleTranslation.convertType(iv.getType()))); ---------------- skatrak wrote:
One thing that I'm thinking for both this case and OpenMP ops that return values is whether it makes sense to use `undef` to represent them temporarily until they are removed or something else, rather than `alloca`. https://github.com/llvm/llvm-project/pull/130078 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits