================ @@ -5150,11 +5213,17 @@ handleDeclareTargetMapVar(MapInfoData &mapData, for (llvm::User *user : userVec) { if (auto *insn = dyn_cast<llvm::Instruction>(user)) { if (insn->getFunction() == func) { - builder.SetCurrentDebugLocation(insn->getDebugLoc()); - auto *load = builder.CreateLoad(mapData.BasePointers[i]->getType(), - mapData.BasePointers[i]); - load->moveBefore(insn->getIterator()); - user->replaceUsesOfWith(mapData.OriginalValue[i], load); + auto mapOp = cast<omp::MapInfoOp>(mapData.MapClause[i]); + llvm::Value *substitute = mapData.BasePointers[i]; + if (isDeclareTargetLink(mapOp.getVarPtrPtr() ? mapOp.getVarPtrPtr() + : mapOp.getVarPtr())) { + builder.SetCurrentDebugLocation(insn->getDebugLoc()); + auto *load = builder.CreateLoad( + mapData.BasePointers[i]->getType(), mapData.BasePointers[i]); + load->moveBefore(insn); + substitute = load; ---------------- skatrak wrote:
```suggestion substitute = builder.CreateLoad( mapData.BasePointers[i]->getType(), mapData.BasePointers[i]); substitute->moveBefore(insn); ``` https://github.com/llvm/llvm-project/pull/119589 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits