ggeorgakoudis created this revision. Herald added subscribers: mgrang, guansong, yaxunl. ggeorgakoudis requested review of this revision. Herald added a reviewer: jdoerfert. Herald added subscribers: cfe-commits, sstefan1. Herald added a project: clang.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D101739 Files: clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/CodeGen/CGOpenMPRuntime.h clang/lib/CodeGen/CGStmtOpenMP.cpp Index: clang/lib/CodeGen/CGStmtOpenMP.cpp =================================================================== --- clang/lib/CodeGen/CGStmtOpenMP.cpp +++ clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -4339,7 +4339,8 @@ auto &&CodeGen = [&Data, &S, CS, &BodyGen, &LastprivateDstsOrigs, CapturedRegion](CodeGenFunction &CGF, PrePostActionTy &Action) { - llvm::DenseMap<CanonicalDeclPtr<const VarDecl>, std::pair<Address, Address>> + llvm::MapVector<CanonicalDeclPtr<const VarDecl>, + std::pair<Address, Address>> UntiedLocalVars; // Set proper addresses for generated private copies. OMPPrivateScope Scope(CGF); @@ -4392,7 +4393,12 @@ Ty = CGF.getContext().getPointerType(Ty); Address PrivatePtr = CGF.CreateMemTemp( CGF.getContext().getPointerType(Ty), ".local.ptr.addr"); - UntiedLocalVars.try_emplace(VD, PrivatePtr, Address::invalid()); + auto Result = UntiedLocalVars.insert( + std::make_pair(VD, std::make_pair(PrivatePtr, Address::invalid()))); + // If key exists update in place. + if (Result.second == false) + *Result.first = std::make_pair( + VD, std::make_pair(PrivatePtr, Address::invalid())); CallArgs.push_back(PrivatePtr.getPointer()); ParamTypes.push_back(PrivatePtr.getType()); } @@ -4424,14 +4430,14 @@ if (isAllocatableDecl(Pair.first)) { llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first); Address Replacement(Ptr, CGF.getPointerAlign()); - Pair.getSecond().first = Replacement; + Pair.second.first = Replacement; Ptr = CGF.Builder.CreateLoad(Replacement); Replacement = Address(Ptr, CGF.getContext().getDeclAlign(Pair.first)); - Pair.getSecond().second = Replacement; + Pair.second.second = Replacement; } else { llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first); Address Replacement(Ptr, CGF.getContext().getDeclAlign(Pair.first)); - Pair.getSecond().first = Replacement; + Pair.second.first = Replacement; } } } Index: clang/lib/CodeGen/CGOpenMPRuntime.h =================================================================== --- clang/lib/CodeGen/CGOpenMPRuntime.h +++ clang/lib/CodeGen/CGOpenMPRuntime.h @@ -253,8 +253,8 @@ public: UntiedTaskLocalDeclsRAII( CodeGenFunction &CGF, - const llvm::DenseMap<CanonicalDeclPtr<const VarDecl>, - std::pair<Address, Address>> &LocalVars); + const llvm::MapVector<CanonicalDeclPtr<const VarDecl>, + std::pair<Address, Address>> &LocalVars); ~UntiedTaskLocalDeclsRAII(); }; @@ -723,8 +723,8 @@ llvm::SmallVector<NontemporalDeclsSet, 4> NontemporalDeclsStack; using UntiedLocalVarsAddressesMap = - llvm::DenseMap<CanonicalDeclPtr<const VarDecl>, - std::pair<Address, Address>>; + llvm::MapVector<CanonicalDeclPtr<const VarDecl>, + std::pair<Address, Address>>; llvm::SmallVector<UntiedLocalVarsAddressesMap, 4> UntiedLocalVarsStack; /// Stack for list of addresses of declarations in current context marked as Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp =================================================================== --- clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -12107,8 +12107,8 @@ CGOpenMPRuntime::UntiedTaskLocalDeclsRAII::UntiedTaskLocalDeclsRAII( CodeGenFunction &CGF, - const llvm::DenseMap<CanonicalDeclPtr<const VarDecl>, - std::pair<Address, Address>> &LocalVars) + const llvm::MapVector<CanonicalDeclPtr<const VarDecl>, + std::pair<Address, Address>> &LocalVars) : CGM(CGF.CGM), NeedToPush(!LocalVars.empty()) { if (!NeedToPush) return;
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp =================================================================== --- clang/lib/CodeGen/CGStmtOpenMP.cpp +++ clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -4339,7 +4339,8 @@ auto &&CodeGen = [&Data, &S, CS, &BodyGen, &LastprivateDstsOrigs, CapturedRegion](CodeGenFunction &CGF, PrePostActionTy &Action) { - llvm::DenseMap<CanonicalDeclPtr<const VarDecl>, std::pair<Address, Address>> + llvm::MapVector<CanonicalDeclPtr<const VarDecl>, + std::pair<Address, Address>> UntiedLocalVars; // Set proper addresses for generated private copies. OMPPrivateScope Scope(CGF); @@ -4392,7 +4393,12 @@ Ty = CGF.getContext().getPointerType(Ty); Address PrivatePtr = CGF.CreateMemTemp( CGF.getContext().getPointerType(Ty), ".local.ptr.addr"); - UntiedLocalVars.try_emplace(VD, PrivatePtr, Address::invalid()); + auto Result = UntiedLocalVars.insert( + std::make_pair(VD, std::make_pair(PrivatePtr, Address::invalid()))); + // If key exists update in place. + if (Result.second == false) + *Result.first = std::make_pair( + VD, std::make_pair(PrivatePtr, Address::invalid())); CallArgs.push_back(PrivatePtr.getPointer()); ParamTypes.push_back(PrivatePtr.getType()); } @@ -4424,14 +4430,14 @@ if (isAllocatableDecl(Pair.first)) { llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first); Address Replacement(Ptr, CGF.getPointerAlign()); - Pair.getSecond().first = Replacement; + Pair.second.first = Replacement; Ptr = CGF.Builder.CreateLoad(Replacement); Replacement = Address(Ptr, CGF.getContext().getDeclAlign(Pair.first)); - Pair.getSecond().second = Replacement; + Pair.second.second = Replacement; } else { llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first); Address Replacement(Ptr, CGF.getContext().getDeclAlign(Pair.first)); - Pair.getSecond().first = Replacement; + Pair.second.first = Replacement; } } } Index: clang/lib/CodeGen/CGOpenMPRuntime.h =================================================================== --- clang/lib/CodeGen/CGOpenMPRuntime.h +++ clang/lib/CodeGen/CGOpenMPRuntime.h @@ -253,8 +253,8 @@ public: UntiedTaskLocalDeclsRAII( CodeGenFunction &CGF, - const llvm::DenseMap<CanonicalDeclPtr<const VarDecl>, - std::pair<Address, Address>> &LocalVars); + const llvm::MapVector<CanonicalDeclPtr<const VarDecl>, + std::pair<Address, Address>> &LocalVars); ~UntiedTaskLocalDeclsRAII(); }; @@ -723,8 +723,8 @@ llvm::SmallVector<NontemporalDeclsSet, 4> NontemporalDeclsStack; using UntiedLocalVarsAddressesMap = - llvm::DenseMap<CanonicalDeclPtr<const VarDecl>, - std::pair<Address, Address>>; + llvm::MapVector<CanonicalDeclPtr<const VarDecl>, + std::pair<Address, Address>>; llvm::SmallVector<UntiedLocalVarsAddressesMap, 4> UntiedLocalVarsStack; /// Stack for list of addresses of declarations in current context marked as Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp =================================================================== --- clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -12107,8 +12107,8 @@ CGOpenMPRuntime::UntiedTaskLocalDeclsRAII::UntiedTaskLocalDeclsRAII( CodeGenFunction &CGF, - const llvm::DenseMap<CanonicalDeclPtr<const VarDecl>, - std::pair<Address, Address>> &LocalVars) + const llvm::MapVector<CanonicalDeclPtr<const VarDecl>, + std::pair<Address, Address>> &LocalVars) : CGM(CGF.CGM), NeedToPush(!LocalVars.empty()) { if (!NeedToPush) return;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits