diff options
author | Samuel Antao <sfantao@us.ibm.com> | 2015-07-27 16:38:06 +0000 |
---|---|---|
committer | Samuel Antao <sfantao@us.ibm.com> | 2015-07-27 16:38:06 +0000 |
commit | 9c75cfe976a65e99d38cfa1f054f91c8043e91ad (patch) | |
tree | 61ade6e40acad2a5e32af772ab6b757501bfffe1 /clang/lib/CodeGen | |
parent | c6f2732e84ec03f7e75deecc9f390199444d5849 (diff) | |
download | bcm5719-llvm-9c75cfe976a65e99d38cfa1f054f91c8043e91ad.tar.gz bcm5719-llvm-9c75cfe976a65e99d38cfa1f054f91c8043e91ad.zip |
[OpenMP] Add capture for threadprivate variables used in copyin clause
if TLS is enabled in OpenMP code generation.
llvm-svn: 243277
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 2069e9a2974..04b4731e853 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -227,10 +227,22 @@ bool CodeGenFunction::EmitOMPCopyinClause(const OMPExecutableDirective &D) { auto *VD = cast<VarDecl>(cast<DeclRefExpr>(*IRef)->getDecl()); QualType Type = VD->getType(); if (CopiedVars.insert(VD->getCanonicalDecl()).second) { - // Get the address of the master variable. - auto *MasterAddr = VD->isStaticLocal() - ? CGM.getStaticLocalDeclAddress(VD) - : CGM.GetAddrOfGlobal(VD); + + // Get the address of the master variable. If we are emitting code with + // TLS support, the address is passed from the master as field in the + // captured declaration. + llvm::Value *MasterAddr; + if (getLangOpts().OpenMPUseTLS && + getContext().getTargetInfo().isTLSSupported()) { + assert(CapturedStmtInfo->lookup(VD) && + "Copyin threadprivates should have been captured!"); + DeclRefExpr DRE(const_cast<VarDecl *>(VD), true, (*IRef)->getType(), + VK_LValue, (*IRef)->getExprLoc()); + MasterAddr = EmitLValue(&DRE).getAddress(); + } else { + MasterAddr = VD->isStaticLocal() ? CGM.getStaticLocalDeclAddress(VD) + : CGM.GetAddrOfGlobal(VD); + } // Get the address of the threadprivate variable. auto *PrivateAddr = EmitLValue(*IRef).getAddress(); if (CopiedVars.size() == 1) { |