diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2019-12-31 12:41:57 -0500 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2019-12-31 14:11:36 -0500 |
commit | 8be5a0fe12bb9114bb82986b1dcb9205699aa085 (patch) | |
tree | 0a92eacadf0e967555cf4acb053e49a272f4d1ec /clang/lib/CodeGen/CGOpenMPRuntime.cpp | |
parent | 7544cb8807b2ecb2f5186ab18d0ffa865a493a47 (diff) | |
download | bcm5719-llvm-8be5a0fe12bb9114bb82986b1dcb9205699aa085.tar.gz bcm5719-llvm-8be5a0fe12bb9114bb82986b1dcb9205699aa085.zip |
[OPENMP]Emit artificial threprivate vars as threadlocal, if possible.
It may improve performance for declare reduction constructs.
Diffstat (limited to 'clang/lib/CodeGen/CGOpenMPRuntime.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 00f8fb570b3..59f352dcd4c 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -3043,10 +3043,15 @@ Address CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF, QualType VarType, StringRef Name) { std::string Suffix = getName({"artificial", ""}); - std::string CacheSuffix = getName({"cache", ""}); llvm::Type *VarLVType = CGF.ConvertTypeForMem(VarType); llvm::Value *GAddr = getOrCreateInternalVariable(VarLVType, Twine(Name).concat(Suffix)); + if (CGM.getLangOpts().OpenMP && CGM.getLangOpts().OpenMPUseTLS && + CGM.getTarget().isTLSSupported()) { + cast<llvm::GlobalVariable>(GAddr)->setThreadLocal(/*Val=*/true); + return Address(GAddr, CGM.getContext().getTypeAlignInChars(VarType)); + } + std::string CacheSuffix = getName({"cache", ""}); llvm::Value *Args[] = { emitUpdateLocation(CGF, SourceLocation()), getThreadID(CGF, SourceLocation()), @@ -3060,7 +3065,7 @@ Address CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF, CGF.EmitRuntimeCall( createRuntimeFunction(OMPRTL__kmpc_threadprivate_cached), Args), VarLVType->getPointerTo(/*AddrSpace=*/0)), - CGM.getPointerAlign()); + CGM.getContext().getTypeAlignInChars(VarType)); } void CGOpenMPRuntime::emitIfClause(CodeGenFunction &CGF, const Expr *Cond, |