@@ -1644,7 +1644,7 @@ Address CGOpenMPRuntime::getAddrOfDeclareTargetVar(const VarDecl *VD) {
1644
1644
QualType PtrTy = CGM.getContext().getPointerType(VD->getType());
1645
1645
llvm::Type *LlvmPtrTy = CGM.getTypes().ConvertTypeForMem(PtrTy);
1646
1646
if (!Ptr) {
1647
- Ptr = getOrCreateInternalVariable(LlvmPtrTy, PtrName);
1647
+ Ptr = OMPBuilder. getOrCreateInternalVariable(LlvmPtrTy, PtrName);
1648
1648
1649
1649
auto *GV = cast<llvm::GlobalVariable>(Ptr);
1650
1650
GV->setLinkage(llvm::GlobalValue::WeakAnyLinkage);
@@ -1664,8 +1664,8 @@ CGOpenMPRuntime::getOrCreateThreadPrivateCache(const VarDecl *VD) {
1664
1664
!CGM.getContext().getTargetInfo().isTLSSupported());
1665
1665
// Lookup the entry, lazily creating it if necessary.
1666
1666
std::string Suffix = getName({"cache", ""});
1667
- return getOrCreateInternalVariable(
1668
- CGM.Int8PtrPtrTy, Twine(CGM.getMangledName(VD)).concat(Suffix));
1667
+ return OMPBuilder. getOrCreateInternalVariable(
1668
+ CGM.Int8PtrPtrTy, Twine(CGM.getMangledName(VD)).concat(Suffix).str() );
1669
1669
}
1670
1670
1671
1671
Address CGOpenMPRuntime::getAddrOfThreadPrivate(CodeGenFunction &CGF,
@@ -1969,8 +1969,8 @@ Address CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF,
1969
1969
StringRef Name) {
1970
1970
std::string Suffix = getName({"artificial", ""});
1971
1971
llvm::Type *VarLVType = CGF.ConvertTypeForMem(VarType);
1972
- llvm::GlobalVariable *GAddr =
1973
- getOrCreateInternalVariable( VarLVType, Twine(Name).concat(Suffix));
1972
+ llvm::GlobalVariable *GAddr = OMPBuilder.getOrCreateInternalVariable(
1973
+ VarLVType, Twine(Name).concat(Suffix).str( ));
1974
1974
if (CGM.getLangOpts().OpenMP && CGM.getLangOpts().OpenMPUseTLS &&
1975
1975
CGM.getTarget().isTLSSupported()) {
1976
1976
GAddr->setThreadLocal(/*Val=*/true);
@@ -1984,8 +1984,9 @@ Address CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF,
1984
1984
CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(GAddr, CGM.VoidPtrTy),
1985
1985
CGF.Builder.CreateIntCast(CGF.getTypeSize(VarType), CGM.SizeTy,
1986
1986
/*isSigned=*/false),
1987
- getOrCreateInternalVariable(
1988
- CGM.VoidPtrPtrTy, Twine(Name).concat(Suffix).concat(CacheSuffix))};
1987
+ OMPBuilder.getOrCreateInternalVariable(
1988
+ CGM.VoidPtrPtrTy,
1989
+ Twine(Name).concat(Suffix).concat(CacheSuffix).str())};
1989
1990
return Address(
1990
1991
CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
1991
1992
CGF.EmitRuntimeCall(
@@ -2130,30 +2131,10 @@ Address CGOpenMPRuntime::emitThreadIDAddress(CodeGenFunction &CGF,
2130
2131
return ThreadIDTemp;
2131
2132
}
2132
2133
2133
- llvm::GlobalVariable *CGOpenMPRuntime::getOrCreateInternalVariable(
2134
- llvm::Type *Ty, const llvm::Twine &Name, unsigned AddressSpace) {
2135
- SmallString<256> Buffer;
2136
- llvm::raw_svector_ostream Out(Buffer);
2137
- Out << Name;
2138
- StringRef RuntimeName = Out.str();
2139
- auto &Elem = *InternalVars.try_emplace(RuntimeName, nullptr).first;
2140
- if (Elem.second) {
2141
- assert(Elem.second->getType()->isOpaqueOrPointeeTypeMatches(Ty) &&
2142
- "OMP internal variable has different type than requested");
2143
- return &*Elem.second;
2144
- }
2145
-
2146
- return Elem.second = new llvm::GlobalVariable(
2147
- CGM.getModule(), Ty, /*IsConstant*/ false,
2148
- llvm::GlobalValue::CommonLinkage, llvm::Constant::getNullValue(Ty),
2149
- Elem.first(), /*InsertBefore=*/nullptr,
2150
- llvm::GlobalValue::NotThreadLocal, AddressSpace);
2151
- }
2152
-
2153
2134
llvm::Value *CGOpenMPRuntime::getCriticalRegionLock(StringRef CriticalName) {
2154
2135
std::string Prefix = Twine("gomp_critical_user_", CriticalName).str();
2155
2136
std::string Name = getName({Prefix, "var"});
2156
- return getOrCreateInternalVariable(KmpCriticalNameTy, Name);
2137
+ return OMPBuilder. getOrCreateInternalVariable(KmpCriticalNameTy, Name);
2157
2138
}
2158
2139
2159
2140
namespace {
@@ -10402,7 +10383,7 @@ void CGOpenMPRuntime::registerTargetGlobalVariable(const VarDecl *VD,
10402
10383
std::string RefName = getName({VarName, "ref"});
10403
10384
if (!CGM.GetGlobalValue(RefName)) {
10404
10385
llvm::Constant *AddrRef =
10405
- getOrCreateInternalVariable(Addr->getType(), RefName);
10386
+ OMPBuilder. getOrCreateInternalVariable(Addr->getType(), RefName);
10406
10387
auto *GVAddrRef = cast<llvm::GlobalVariable>(AddrRef);
10407
10388
GVAddrRef->setConstant(/*Val=*/true);
10408
10389
GVAddrRef->setLinkage(llvm::GlobalValue::InternalLinkage);
@@ -12195,15 +12176,15 @@ void CGOpenMPRuntime::emitLastprivateConditionalUpdate(CodeGenFunction &CGF,
12195
12176
// Last updated loop counter for the lastprivate conditional var.
12196
12177
// int<xx> last_iv = 0;
12197
12178
llvm::Type *LLIVTy = CGF.ConvertTypeForMem(IVLVal.getType());
12198
- llvm::Constant *LastIV =
12199
- getOrCreateInternalVariable( LLIVTy, getName({UniqueDeclName, "iv"}));
12179
+ llvm::Constant *LastIV = OMPBuilder.getOrCreateInternalVariable(
12180
+ LLIVTy, getName({UniqueDeclName, "iv"}));
12200
12181
cast<llvm::GlobalVariable>(LastIV)->setAlignment(
12201
12182
IVLVal.getAlignment().getAsAlign());
12202
12183
LValue LastIVLVal = CGF.MakeNaturalAlignAddrLValue(LastIV, IVLVal.getType());
12203
12184
12204
12185
// Last value of the lastprivate conditional.
12205
12186
// decltype(priv_a) last_a;
12206
- llvm::GlobalVariable *Last = getOrCreateInternalVariable(
12187
+ llvm::GlobalVariable *Last = OMPBuilder. getOrCreateInternalVariable(
12207
12188
CGF.ConvertTypeForMem(LVal.getType()), UniqueDeclName);
12208
12189
Last->setAlignment(LVal.getAlignment().getAsAlign());
12209
12190
LValue LastLVal = CGF.MakeAddrLValue(
0 commit comments