From: Jennifer Yu Date: Wed, 2 Nov 2022 22:43:26 +0000 (-0700) Subject: Remove redundant loads. X-Git-Tag: upstream/17.0.6~28472 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de14befa7730093ff3d46c7628fa1084f251e98d;p=platform%2Fupstream%2Fllvm.git Remove redundant loads. It is caused by regenerate captured var value when processing the has_device_addr, the captured var value has been generated in GenerateOpenMPCapturedVars and passed as Arg in generateInfoForCapture. The fix just use Arg instead regenerated just same as is_device_ptr --- diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index e52989b..b87e69b 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -8739,7 +8739,7 @@ public: // If this declaration appears in a is_device_ptr clause we just have to // pass the pointer by value. If it is a reference to a declaration, we just // pass its value. - if (VD && DevPointersMap.count(VD)) { + if (VD && (DevPointersMap.count(VD) || HasDevAddrsMap.count(VD))) { CombinedInfo.Exprs.push_back(VD); CombinedInfo.BasePointers.emplace_back(Arg, VD); CombinedInfo.Pointers.push_back(Arg); @@ -8752,30 +8752,6 @@ public: CombinedInfo.Mappers.push_back(nullptr); return; } - if (VD && HasDevAddrsMap.count(VD)) { - auto I = HasDevAddrsMap.find(VD); - CombinedInfo.Exprs.push_back(VD); - Expr *E = nullptr; - for (auto &MCL : I->second) { - E = MCL.begin()->getAssociatedExpression(); - break; - } - llvm::Value *Ptr = nullptr; - if (E->isGLValue()) - Ptr = CGF.EmitLValue(E).getPointer(CGF); - else - Ptr = CGF.EmitScalarExpr(E); - CombinedInfo.BasePointers.emplace_back(Ptr, VD); - CombinedInfo.Pointers.push_back(Ptr); - CombinedInfo.Sizes.push_back(CGF.Builder.CreateIntCast( - CGF.getTypeSize(CGF.getContext().VoidPtrTy), CGF.Int64Ty, - /*isSigned=*/true)); - CombinedInfo.Types.push_back( - (Cap->capturesVariable() ? OMP_MAP_TO : OMP_MAP_LITERAL) | - OMP_MAP_TARGET_PARAM); - CombinedInfo.Mappers.push_back(nullptr); - return; - } using MapData = std::tuple