<div dir="ltr">The test is incompatible to i686-pc-win32. See also <a href="http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/5498">http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/5498</a></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Feb 8, 2016 at 6:33 PM Alexey Bataev via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: abataev<br>
Date: Mon Feb 8 03:29:13 2016<br>
New Revision: 260077<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=260077&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=260077&view=rev</a><br>
Log:<br>
[OPENMP 4.5] Ccapture/codegen of private non-static data members.<br>
OpenMP 4.5 introduces privatization of non-static data members of current class in non-static member functions.<br>
To correctly handle such kind of privatization a new (pseudo)declaration VarDecl-based node is added. It allows to reuse an existing code for capturing variables in Lambdas/Block/Captured blocks of code for correct privatization and codegen.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/AST/DeclOpenMP.h<br>
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h<br>
cfe/trunk/include/clang/Basic/DeclNodes.td<br>
cfe/trunk/include/clang/Sema/Sema.h<br>
cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br>
cfe/trunk/lib/AST/DeclBase.cpp<br>
cfe/trunk/lib/AST/DeclOpenMP.cpp<br>
cfe/trunk/lib/AST/DeclPrinter.cpp<br>
cfe/trunk/lib/AST/StmtPrinter.cpp<br>
cfe/trunk/lib/CodeGen/CGDecl.cpp<br>
cfe/trunk/lib/Sema/SemaExpr.cpp<br>
cfe/trunk/lib/Sema/SemaExprMember.cpp<br>
cfe/trunk/lib/Sema/SemaOpenMP.cpp<br>
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp<br>
cfe/trunk/lib/Serialization/ASTCommon.cpp<br>
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp<br>
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp<br>
cfe/trunk/test/OpenMP/parallel_private_codegen.cpp<br>
cfe/trunk/tools/libclang/CIndex.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/DeclOpenMP.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclOpenMP.h?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclOpenMP.h?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/DeclOpenMP.h (original)<br>
+++ cfe/trunk/include/clang/AST/DeclOpenMP.h Mon Feb 8 03:29:13 2016<br>
@@ -87,6 +87,35 @@ public:<br>
static bool classofKind(Kind K) { return K == OMPThreadPrivate; }<br>
};<br>
<br>
-} // end namespace clang<br>
+/// Pseudo declaration for capturing of non-static data members in non-static<br>
+/// member functions.<br>
+///<br>
+/// Clang supports capturing of variables only, but OpenMP 4.5 allows to<br>
+/// privatize non-static members of current class in non-static member<br>
+/// functions. This pseudo-declaration allows properly handle this kind of<br>
+/// capture by wrapping captured expression into a variable-like declaration.<br>
+class OMPCapturedFieldDecl final : public VarDecl {<br>
+ friend class ASTDeclReader;<br>
+ void anchor() override;<br>
+<br>
+ OMPCapturedFieldDecl(ASTContext &C, DeclContext *DC, IdentifierInfo *Id,<br>
+ QualType Type)<br>
+ : VarDecl(OMPCapturedField, C, DC, SourceLocation(), SourceLocation(), Id,<br>
+ Type, nullptr, SC_None) {<br>
+ setImplicit();<br>
+ }<br>
+<br>
+public:<br>
+ static OMPCapturedFieldDecl *Create(ASTContext &C, DeclContext *DC,<br>
+ IdentifierInfo *Id, QualType T);<br>
+<br>
+ static OMPCapturedFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID);<br>
+<br>
+ // Implement isa/cast/dyncast/etc.<br>
+ static bool classof(const Decl *D) { return classofKind(D->getKind()); }<br>
+ static bool classofKind(Kind K) { return K == OMPCapturedField; }<br>
+};<br>
+<br>
+} // end namespace clang<br>
<br>
#endif<br>
<br>
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)<br>
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Feb 8 03:29:13 2016<br>
@@ -1434,6 +1434,8 @@ DEF_TRAVERSE_DECL(OMPThreadPrivateDecl,<br>
}<br>
})<br>
<br>
+DEF_TRAVERSE_DECL(OMPCapturedFieldDecl, { TRY_TO(TraverseVarHelper(D)); })<br>
+<br>
// A helper method for TemplateDecl's children.<br>
template <typename Derived><br>
bool RecursiveASTVisitor<Derived>::TraverseTemplateParameterListHelper(<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DeclNodes.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DeclNodes.td?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DeclNodes.td?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DeclNodes.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DeclNodes.td Mon Feb 8 03:29:13 2016<br>
@@ -51,6 +51,7 @@ def Named : Decl<1>;<br>
: DDecl<VarTemplateSpecialization>;<br>
def ImplicitParam : DDecl<Var>;<br>
def ParmVar : DDecl<Var>;<br>
+ def OMPCapturedField : DDecl<Var>;<br>
def NonTypeTemplateParm : DDecl<Declarator>;<br>
def Template : DDecl<Named, 1>;<br>
def RedeclarableTemplate : DDecl<Template, 1>;<br>
<br>
Modified: cfe/trunk/include/clang/Sema/Sema.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Sema/Sema.h (original)<br>
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Feb 8 03:29:13 2016<br>
@@ -7789,7 +7789,9 @@ public:<br>
/// \brief Check if the specified variable is used in one of the private<br>
/// clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP<br>
/// constructs.<br>
- bool IsOpenMPCapturedDecl(ValueDecl *D);<br>
+ VarDecl *IsOpenMPCapturedDecl(ValueDecl *D);<br>
+ ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK,<br>
+ ExprObjectKind OK);<br>
<br>
/// \brief Check if the specified variable is used in 'private' clause.<br>
/// \param Level Relative level of nested OpenMP construct for that the check<br>
<br>
Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)<br>
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Mon Feb 8 03:29:13 2016<br>
@@ -1163,6 +1163,8 @@ namespace clang {<br>
DECL_EMPTY,<br>
/// \brief An ObjCTypeParamDecl record.<br>
DECL_OBJC_TYPE_PARAM,<br>
+ /// \brief An OMPCapturedFieldDecl record.<br>
+ DECL_OMP_CAPTUREDFIELD,<br>
};<br>
<br>
/// \brief Record codes for each kind of statement or expression.<br>
<br>
Modified: cfe/trunk/lib/AST/DeclBase.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/DeclBase.cpp (original)<br>
+++ cfe/trunk/lib/AST/DeclBase.cpp Mon Feb 8 03:29:13 2016<br>
@@ -655,6 +655,7 @@ unsigned Decl::getIdentifierNamespaceFor<br>
case ObjCCategoryImpl:<br>
case Import:<br>
case OMPThreadPrivate:<br>
+ case OMPCapturedField:<br>
case Empty:<br>
// Never looked up by name.<br>
return 0;<br>
<br>
Modified: cfe/trunk/lib/AST/DeclOpenMP.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclOpenMP.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclOpenMP.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/DeclOpenMP.cpp (original)<br>
+++ cfe/trunk/lib/AST/DeclOpenMP.cpp Mon Feb 8 03:29:13 2016<br>
@@ -7,7 +7,8 @@<br>
//<br>
//===----------------------------------------------------------------------===//<br>
/// \file<br>
-/// \brief This file implements OMPThreadPrivateDecl class.<br>
+/// \brief This file implements OMPThreadPrivateDecl, OMPCapturedFieldDecl<br>
+/// classes.<br>
///<br>
//===----------------------------------------------------------------------===//<br>
<br>
@@ -52,3 +53,21 @@ void OMPThreadPrivateDecl::setVars(Array<br>
std::uninitialized_copy(VL.begin(), VL.end(), getTrailingObjects<Expr *>());<br>
}<br>
<br>
+//===----------------------------------------------------------------------===//<br>
+// OMPCapturedFieldDecl Implementation.<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+void OMPCapturedFieldDecl::anchor() {}<br>
+<br>
+OMPCapturedFieldDecl *OMPCapturedFieldDecl::Create(ASTContext &C,<br>
+ DeclContext *DC,<br>
+ IdentifierInfo *Id,<br>
+ QualType T) {<br>
+ return new (C, DC) OMPCapturedFieldDecl(C, DC, Id, T);<br>
+}<br>
+<br>
+OMPCapturedFieldDecl *OMPCapturedFieldDecl::CreateDeserialized(ASTContext &C,<br>
+ unsigned ID) {<br>
+ return new (C, ID) OMPCapturedFieldDecl(C, nullptr, nullptr, QualType());<br>
+}<br>
+<br>
<br>
Modified: cfe/trunk/lib/AST/DeclPrinter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)<br>
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Feb 8 03:29:13 2016<br>
@@ -92,6 +92,7 @@ namespace {<br>
void VisitUsingDecl(UsingDecl *D);<br>
void VisitUsingShadowDecl(UsingShadowDecl *D);<br>
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);<br>
+ void VisitOMPCapturedFieldDecl(OMPCapturedFieldDecl *D);<br>
<br>
void PrintTemplateParameters(const TemplateParameterList *Params,<br>
const TemplateArgumentList *Args = nullptr);<br>
@@ -1366,3 +1367,7 @@ void DeclPrinter::VisitOMPThreadPrivateD<br>
}<br>
}<br>
<br>
+void DeclPrinter::VisitOMPCapturedFieldDecl(OMPCapturedFieldDecl *D) {<br>
+ D->getInit()->printPretty(Out, nullptr, Policy, Indentation);<br>
+}<br>
+<br>
<br>
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)<br>
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Feb 8 03:29:13 2016<br>
@@ -16,6 +16,7 @@<br>
#include "clang/AST/Attr.h"<br>
#include "clang/AST/DeclCXX.h"<br>
#include "clang/AST/DeclObjC.h"<br>
+#include "clang/AST/DeclOpenMP.h"<br>
#include "clang/AST/DeclTemplate.h"<br>
#include "clang/AST/Expr.h"<br>
#include "clang/AST/ExprCXX.h"<br>
@@ -763,15 +764,16 @@ template<typename T><br>
void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {<br>
for (typename T::varlist_iterator I = Node->varlist_begin(),<br>
E = Node->varlist_end();<br>
- I != E; ++I) {<br>
+ I != E; ++I) {<br>
assert(*I && "Expected non-null Stmt");<br>
+ OS << (I == Node->varlist_begin() ? StartSym : ',');<br>
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(*I)) {<br>
- OS << (I == Node->varlist_begin() ? StartSym : ',');<br>
- cast<NamedDecl>(DRE->getDecl())->printQualifiedName(OS);<br>
- } else {<br>
- OS << (I == Node->varlist_begin() ? StartSym : ',');<br>
+ if (auto *CFD = dyn_cast<OMPCapturedFieldDecl>(DRE->getDecl()))<br>
+ CFD->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy, 0);<br>
+ else<br>
+ DRE->getDecl()->printQualifiedName(OS);<br>
+ } else<br>
(*I)->printPretty(OS, nullptr, Policy, 0);<br>
- }<br>
}<br>
}<br>
<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Mon Feb 8 03:29:13 2016<br>
@@ -92,6 +92,7 @@ void CodeGenFunction::EmitDecl(const Dec<br>
case Decl::Label: // __label__ x;<br>
case Decl::Import:<br>
case Decl::OMPThreadPrivate:<br>
+ case Decl::OMPCapturedField:<br>
case Decl::Empty:<br>
// None of these decls require codegen support.<br>
return;<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Feb 8 03:29:13 2016<br>
@@ -2874,6 +2874,7 @@ ExprResult Sema::BuildDeclarationNameExp<br>
case Decl::Var:<br>
case Decl::VarTemplateSpecialization:<br>
case Decl::VarTemplatePartialSpecialization:<br>
+ case Decl::OMPCapturedField:<br>
// In C, "extern void blah;" is valid and is an r-value.<br>
if (!getLangOpts().CPlusPlus &&<br>
!type.hasQualifiers() &&<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Mon Feb 8 03:29:13 2016<br>
@@ -1735,9 +1735,19 @@ BuildFieldReferenceExpr(Sema &S, Expr *B<br>
FoundDecl, Field);<br>
if (Base.isInvalid())<br>
return ExprError();<br>
- return BuildMemberExpr(S, S.Context, Base.get(), IsArrow, OpLoc, SS,<br>
- /*TemplateKWLoc=*/SourceLocation(), Field, FoundDecl,<br>
- MemberNameInfo, MemberType, VK, OK);<br>
+ MemberExpr *ME =<br>
+ BuildMemberExpr(S, S.Context, Base.get(), IsArrow, OpLoc, SS,<br>
+ /*TemplateKWLoc=*/SourceLocation(), Field, FoundDecl,<br>
+ MemberNameInfo, MemberType, VK, OK);<br>
+<br>
+ // Build a reference to a private copy for non-static data members in<br>
+ // non-static member functions, privatized by OpenMP constructs.<br>
+ if (S.getLangOpts().OpenMP && IsArrow &&<br>
+ isa<CXXThisExpr>(Base.get()->IgnoreParenImpCasts())) {<br>
+ if (auto *PrivateCopy = S.IsOpenMPCapturedDecl(Field))<br>
+ return S.getOpenMPCapturedExpr(PrivateCopy, VK, OK);<br>
+ }<br>
+ return ME;<br>
}<br>
<br>
/// Builds an implicit member access expression. The current context<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Feb 8 03:29:13 2016<br>
@@ -71,10 +71,11 @@ public:<br>
OpenMPDirectiveKind DKind;<br>
OpenMPClauseKind CKind;<br>
Expr *RefExpr;<br>
+ DeclRefExpr *PrivateCopy;<br>
SourceLocation ImplicitDSALoc;<br>
DSAVarData()<br>
: DKind(OMPD_unknown), CKind(OMPC_unknown), RefExpr(nullptr),<br>
- ImplicitDSALoc() {}<br>
+ PrivateCopy(nullptr), ImplicitDSALoc() {}<br>
};<br>
<br>
private:<br>
@@ -83,11 +84,12 @@ private:<br>
struct DSAInfo {<br>
OpenMPClauseKind Attributes;<br>
Expr *RefExpr;<br>
+ DeclRefExpr *PrivateCopy;<br>
};<br>
- typedef llvm::SmallDenseMap<ValueDecl *, DSAInfo, 64> DeclSAMapTy;<br>
- typedef llvm::SmallDenseMap<ValueDecl *, Expr *, 64> AlignedMapTy;<br>
+ typedef llvm::DenseMap<ValueDecl *, DSAInfo> DeclSAMapTy;<br>
+ typedef llvm::DenseMap<ValueDecl *, Expr *> AlignedMapTy;<br>
typedef llvm::DenseMap<ValueDecl *, unsigned> LoopControlVariablesMapTy;<br>
- typedef llvm::SmallDenseMap<ValueDecl *, MapInfo, 64> MappedDeclsTy;<br>
+ typedef llvm::DenseMap<ValueDecl *, MapInfo> MappedDeclsTy;<br>
typedef llvm::StringMap<std::pair<OMPCriticalDirective *, llvm::APSInt>><br>
CriticalsWithHintsTy;<br>
<br>
@@ -195,7 +197,8 @@ public:<br>
ValueDecl *getParentLoopControlVariable(unsigned I);<br>
<br>
/// \brief Adds explicit data sharing attribute to the specified declaration.<br>
- void addDSA(ValueDecl *D, Expr *E, OpenMPClauseKind A);<br>
+ void addDSA(ValueDecl *D, Expr *E, OpenMPClauseKind A,<br>
+ DeclRefExpr *PrivateCopy = nullptr);<br>
<br>
/// \brief Returns data sharing attributes from top of the stack for the<br>
/// specified declaration.<br>
@@ -434,6 +437,7 @@ DSAStackTy::DSAVarData DSAStackTy::getDS<br>
// attributes.<br>
if (Iter->SharingMap.count(D)) {<br>
DVar.RefExpr = Iter->SharingMap[D].RefExpr;<br>
+ DVar.PrivateCopy = Iter->SharingMap[D].PrivateCopy;<br>
DVar.CKind = Iter->SharingMap[D].Attributes;<br>
DVar.ImplicitDSALoc = Iter->DefaultAttrLoc;<br>
return DVar;<br>
@@ -547,15 +551,20 @@ ValueDecl *DSAStackTy::getParentLoopCont<br>
return nullptr;<br>
}<br>
<br>
-void DSAStackTy::addDSA(ValueDecl *D, Expr *E, OpenMPClauseKind A) {<br>
+void DSAStackTy::addDSA(ValueDecl *D, Expr *E, OpenMPClauseKind A,<br>
+ DeclRefExpr *PrivateCopy) {<br>
D = getCanonicalDecl(D);<br>
if (A == OMPC_threadprivate) {<br>
Stack[0].SharingMap[D].Attributes = A;<br>
Stack[0].SharingMap[D].RefExpr = E;<br>
+ Stack[0].SharingMap[D].PrivateCopy = nullptr;<br>
} else {<br>
assert(Stack.size() > 1 && "Data-sharing attributes stack is empty");<br>
Stack.back().SharingMap[D].Attributes = A;<br>
Stack.back().SharingMap[D].RefExpr = E;<br>
+ Stack.back().SharingMap[D].PrivateCopy = PrivateCopy;<br>
+ if (PrivateCopy)<br>
+ addDSA(PrivateCopy->getDecl(), PrivateCopy, A);<br>
}<br>
}<br>
<br>
@@ -682,6 +691,7 @@ DSAStackTy::DSAVarData DSAStackTy::getTo<br>
auto I = std::prev(StartI);<br>
if (I->SharingMap.count(D)) {<br>
DVar.RefExpr = I->SharingMap[D].RefExpr;<br>
+ DVar.PrivateCopy = I->SharingMap[D].PrivateCopy;<br>
DVar.CKind = I->SharingMap[D].Attributes;<br>
DVar.ImplicitDSALoc = I->DefaultAttrLoc;<br>
}<br>
@@ -886,7 +896,7 @@ bool Sema::IsOpenMPCapturedByRef(ValueDe<br>
return IsByRef;<br>
}<br>
<br>
-bool Sema::IsOpenMPCapturedDecl(ValueDecl *D) {<br>
+VarDecl *Sema::IsOpenMPCapturedDecl(ValueDecl *D) {<br>
assert(LangOpts.OpenMP && "OpenMP is not allowed");<br>
D = getCanonicalDecl(D);<br>
<br>
@@ -900,18 +910,16 @@ bool Sema::IsOpenMPCapturedDecl(ValueDec<br>
auto *VD = dyn_cast<VarDecl>(D);<br>
if (VD && !VD->hasLocalStorage()) {<br>
if (DSAStack->getCurrentDirective() == OMPD_target &&<br>
- !DSAStack->isClauseParsingMode()) {<br>
- return true;<br>
- }<br>
+ !DSAStack->isClauseParsingMode())<br>
+ return VD;<br>
if (DSAStack->getCurScope() &&<br>
DSAStack->hasDirective(<br>
[](OpenMPDirectiveKind K, const DeclarationNameInfo &DNI,<br>
SourceLocation Loc) -> bool {<br>
return isOpenMPTargetExecutionDirective(K);<br>
},<br>
- false)) {<br>
- return true;<br>
- }<br>
+ false))<br>
+ return VD;<br>
}<br>
<br>
if (DSAStack->getCurrentDirective() != OMPD_unknown &&<br>
@@ -921,15 +929,16 @@ bool Sema::IsOpenMPCapturedDecl(ValueDec<br>
(VD && VD->hasLocalStorage() &&<br>
isParallelOrTaskRegion(DSAStack->getCurrentDirective())) ||<br>
(VD && DSAStack->isForceVarCapturing()))<br>
- return true;<br>
+ return VD;<br>
auto DVarPrivate = DSAStack->getTopDSA(D, DSAStack->isClauseParsingMode());<br>
if (DVarPrivate.CKind != OMPC_unknown && isOpenMPPrivate(DVarPrivate.CKind))<br>
- return true;<br>
+ return VD ? VD : cast<VarDecl>(DVarPrivate.PrivateCopy->getDecl());<br>
DVarPrivate = DSAStack->hasDSA(D, isOpenMPPrivate, MatchesAlways(),<br>
DSAStack->isClauseParsingMode());<br>
- return DVarPrivate.CKind != OMPC_unknown;<br>
+ if (DVarPrivate.CKind != OMPC_unknown)<br>
+ return VD ? VD : cast<VarDecl>(DVarPrivate.PrivateCopy->getDecl());<br>
}<br>
- return false;<br>
+ return nullptr;<br>
}<br>
<br>
bool Sema::isOpenMPPrivateDecl(ValueDecl *D, unsigned Level) {<br>
@@ -6958,6 +6967,50 @@ OMPClause *Sema::ActOnOpenMPVarListClaus<br>
return Res;<br>
}<br>
<br>
+static DeclRefExpr *buildCapture(Sema &S, IdentifierInfo *Id,<br>
+ Expr *CaptureExpr) {<br>
+ ASTContext &C = S.getASTContext();<br>
+ Expr *Init = CaptureExpr->IgnoreImpCasts();<br>
+ QualType Ty = Init->getType();<br>
+ if (CaptureExpr->getObjectKind() == OK_Ordinary) {<br>
+ if (S.getLangOpts().CPlusPlus)<br>
+ Ty = C.getLValueReferenceType(Ty);<br>
+ else {<br>
+ Ty = C.getPointerType(Ty);<br>
+ ExprResult Res =<br>
+ S.CreateBuiltinUnaryOp(CaptureExpr->getExprLoc(), UO_AddrOf, Init);<br>
+ if (!Res.isUsable())<br>
+ return nullptr;<br>
+ Init = Res.get();<br>
+ }<br>
+ }<br>
+ auto *CFD = OMPCapturedFieldDecl::Create(C, S.CurContext, Id, Ty);<br>
+ S.CurContext->addHiddenDecl(CFD);<br>
+ S.AddInitializerToDecl(CFD, Init, /*DirectInit=*/false,<br>
+ /*TypeMayContainAuto=*/true);<br>
+ return buildDeclRefExpr(S, CFD, Ty.getNonReferenceType(), SourceLocation());<br>
+}<br>
+<br>
+ExprResult Sema::getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK,<br>
+ ExprObjectKind OK) {<br>
+ SourceLocation Loc = Capture->getInit()->getExprLoc();<br>
+ ExprResult Res = BuildDeclRefExpr(<br>
+ Capture, Capture->getType().getNonReferenceType(), VK_LValue, Loc);<br>
+ if (!Res.isUsable())<br>
+ return ExprError();<br>
+ if (OK == OK_Ordinary && !getLangOpts().CPlusPlus) {<br>
+ Res = CreateBuiltinUnaryOp(Loc, UO_Deref, Res.get());<br>
+ if (!Res.isUsable())<br>
+ return ExprError();<br>
+ }<br>
+ if (VK != VK_LValue && Res.get()->isGLValue()) {<br>
+ Res = DefaultLvalueConversion(Res.get());<br>
+ if (!Res.isUsable())<br>
+ return ExprError();<br>
+ }<br>
+ return Res;<br>
+}<br>
+<br>
OMPClause *Sema::ActOnOpenMPPrivateClause(ArrayRef<Expr *> VarList,<br>
SourceLocation StartLoc,<br>
SourceLocation LParenLoc,<br>
@@ -7050,8 +7103,11 @@ OMPClause *Sema::ActOnOpenMPPrivateClaus<br>
auto VDPrivateRefExpr = buildDeclRefExpr(<br>
*this, VDPrivate, RefExpr->getType().getUnqualifiedType(), ELoc);<br>
<br>
- DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_private);<br>
- Vars.push_back(RefExpr->IgnoreParens());<br>
+ DeclRefExpr *Ref = nullptr;<br>
+ if (!VD)<br>
+ Ref = buildCapture(*this, D->getIdentifier(), RefExpr);<br>
+ DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_private, Ref);<br>
+ Vars.push_back(VD ? RefExpr->IgnoreParens() : Ref);<br>
PrivateCopies.push_back(VDPrivateRefExpr);<br>
}<br>
<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Feb 8 03:29:13 2016<br>
@@ -2483,6 +2483,11 @@ Decl *TemplateDeclInstantiator::VisitOMP<br>
return TD;<br>
}<br>
<br>
+Decl *TemplateDeclInstantiator::VisitOMPCapturedFieldDecl(<br>
+ OMPCapturedFieldDecl * /*D*/) {<br>
+ llvm_unreachable("Should not be met in templates");<br>
+}<br>
+<br>
Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D) {<br>
return VisitFunctionDecl(D, nullptr);<br>
}<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTCommon.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTCommon.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTCommon.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTCommon.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTCommon.cpp Mon Feb 8 03:29:13 2016<br>
@@ -329,6 +329,7 @@ bool serialization::isRedeclarableDeclKi<br>
case Decl::ClassScopeFunctionSpecialization:<br>
case Decl::Import:<br>
case Decl::OMPThreadPrivate:<br>
+ case Decl::OMPCapturedField:<br>
case Decl::BuiltinTemplate:<br>
return false;<br>
<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Mon Feb 8 03:29:13 2016<br>
@@ -350,6 +350,7 @@ namespace clang {<br>
void VisitObjCPropertyDecl(ObjCPropertyDecl *D);<br>
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);<br>
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);<br>
+ void VisitOMPCapturedFieldDecl(OMPCapturedFieldDecl *D);<br>
<br>
/// We've merged the definition \p MergedDef into the existing definition<br>
/// \p Def. Ensure that \p Def is made visible whenever \p MergedDef is made<br>
@@ -2360,6 +2361,10 @@ void ASTDeclReader::VisitOMPThreadPrivat<br>
D->setVars(Vars);<br>
}<br>
<br>
+void ASTDeclReader::VisitOMPCapturedFieldDecl(OMPCapturedFieldDecl *D) {<br>
+ VisitVarDecl(D);<br>
+}<br>
+<br>
//===----------------------------------------------------------------------===//<br>
// Attribute Reading<br>
//===----------------------------------------------------------------------===//<br>
@@ -3323,6 +3328,9 @@ Decl *ASTReader::ReadDeclRecord(DeclID I<br>
case DECL_OMP_THREADPRIVATE:<br>
D = OMPThreadPrivateDecl::CreateDeserialized(Context, ID, Record[Idx++]);<br>
break;<br>
+ case DECL_OMP_CAPTUREDFIELD:<br>
+ D = OMPCapturedFieldDecl::CreateDeserialized(Context, ID);<br>
+ break;<br>
case DECL_EMPTY:<br>
D = EmptyDecl::CreateDeserialized(Context, ID);<br>
break;<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Mon Feb 8 03:29:13 2016<br>
@@ -131,6 +131,7 @@ namespace clang {<br>
void VisitObjCPropertyDecl(ObjCPropertyDecl *D);<br>
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);<br>
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);<br>
+ void VisitOMPCapturedFieldDecl(OMPCapturedFieldDecl *D);<br>
<br>
/// Add an Objective-C type parameter list to the given record.<br>
void AddObjCTypeParamList(ObjCTypeParamList *typeParams) {<br>
@@ -1628,6 +1629,11 @@ void ASTDeclWriter::VisitOMPThreadPrivat<br>
Code = serialization::DECL_OMP_THREADPRIVATE;<br>
}<br>
<br>
+void ASTDeclWriter::VisitOMPCapturedFieldDecl(OMPCapturedFieldDecl *D) {<br>
+ VisitVarDecl(D);<br>
+ Code = serialization::DECL_OMP_CAPTUREDFIELD;<br>
+}<br>
+<br>
//===----------------------------------------------------------------------===//<br>
// ASTWriter Implementation<br>
//===----------------------------------------------------------------------===//<br>
<br>
Modified: cfe/trunk/test/OpenMP/parallel_private_codegen.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_private_codegen.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_private_codegen.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/OpenMP/parallel_private_codegen.cpp (original)<br>
+++ cfe/trunk/test/OpenMP/parallel_private_codegen.cpp Mon Feb 8 03:29:13 2016<br>
@@ -18,11 +18,69 @@ struct S {<br>
<br>
volatile int g __attribute__((aligned(128))) = 1212;<br>
<br>
+struct SS {<br>
+ int a;<br>
+ int b : 4;<br>
+ int &c;<br>
+ SS(int &d) : a(0), b(0), c(d) {<br>
+#pragma omp parallel private(a, b, c)<br>
+#ifdef LAMBDA<br>
+ [&]() {<br>
+ ++this->a, --b, (this)->c /= 1;<br>
+#pragma omp parallel private(a, b, c)<br>
+ ++(this)->a, --b, this->c /= 1;<br>
+ }();<br>
+#elif defined(BLOCKS)<br>
+ ^{<br>
+ ++a;<br>
+ --this->b;<br>
+ (this)->c /= 1;<br>
+#pragma omp parallel private(a, b, c)<br>
+ ++(this)->a, --b, this->c /= 1;<br>
+ }();<br>
+#else<br>
+ ++this->a, --b, c /= 1;<br>
+#endif<br>
+ }<br>
+};<br>
+<br>
+template<typename T><br>
+struct SST {<br>
+ T a;<br>
+ SST() : a(T()) {<br>
+#pragma omp parallel private(a)<br>
+#ifdef LAMBDA<br>
+ [&]() {<br>
+ [&]() {<br>
+ ++this->a;<br>
+#pragma omp parallel private(a)<br>
+ ++(this)->a;<br>
+ }();<br>
+ }();<br>
+#elif defined(BLOCKS)<br>
+ ^{<br>
+ ^{<br>
+ ++a;<br>
+#pragma omp parallel private(a)<br>
+ ++(this)->a;<br>
+ }();<br>
+ }();<br>
+#else<br>
+ ++(this)->a;<br>
+#endif<br>
+ }<br>
+};<br>
+<br>
+// CHECK: [[SS_TY:%.+]] = type { i{{[0-9]+}}, i8<br>
+// LAMBDA: [[SS_TY:%.+]] = type { i{{[0-9]+}}, i8<br>
+// BLOCKS: [[SS_TY:%.+]] = type { i{{[0-9]+}}, i8<br>
// CHECK: [[S_FLOAT_TY:%.+]] = type { float }<br>
// CHECK: [[S_INT_TY:%.+]] = type { i{{[0-9]+}} }<br>
+// CHECK: [[SST_TY:%.+]] = type { i{{[0-9]+}} }<br>
template <typename T><br>
T tmain() {<br>
S<T> test;<br>
+ SST<T> sst;<br>
T t_var __attribute__((aligned(128))) = T();<br>
T vec[] __attribute__((aligned(128))) = {1, 2};<br>
S<T> s_arr[] __attribute__((aligned(128))) = {1, 2};<br>
@@ -37,9 +95,11 @@ T tmain() {<br>
<br>
int main() {<br>
static int sivar;<br>
+ SS ss(sivar);<br>
#ifdef LAMBDA<br>
// LAMBDA: [[G:@.+]] = global i{{[0-9]+}} 1212,<br>
// LAMBDA-LABEL: @main<br>
+ // LAMBDA: call<br>
// LAMBDA: call{{.*}} void [[OUTER_LAMBDA:@.+]](<br>
[&]() {<br>
// LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](<br>
@@ -47,6 +107,36 @@ int main() {<br>
// LAMBDA: call{{.*}} void {{.+}} @__kmpc_fork_call({{.+}}, i32 0, {{.+}}* [[OMP_REGION:@.+]] to {{.+}})<br>
#pragma omp parallel private(g, sivar)<br>
{<br>
+ // LAMBDA: define {{.+}} @{{.+}}([[SS_TY]]* %<br>
+ // LAMBDA: store i{{[0-9]+}} 0, i{{[0-9]+}}* %<br>
+ // LAMBDA: store i8<br>
+ // LAMBDA: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*)* [[SS_MICROTASK:@.+]] to void<br>
+ // LAMBDA: ret<br>
+<br>
+ // LAMBDA: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}})<br>
+ // LAMBDA-NOT: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %<br>
+ // LAMBDA: call{{.*}} void<br>
+ // LAMBDA: ret void<br>
+<br>
+ // LAMBDA: define internal void @{{.+}}(i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}})<br>
+ // LAMBDA: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},<br>
+ // LAMBDA: [[B_PRIV:%.+]] = alloca i{{[0-9]+}},<br>
+ // LAMBDA: [[C_PRIV:%.+]] = alloca i{{[0-9]+}},<br>
+ // LAMBDA: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REFA:%.+]],<br>
+ // LAMBDA: store i{{[0-9]+}}* [[C_PRIV]], i{{[0-9]+}}** [[REFC:%.+]],<br>
+ // LAMBDA-NEXT: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFA]],<br>
+ // LAMBDA-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],<br>
+ // LAMBDA-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1<br>
+ // LAMBDA-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],<br>
+ // LAMBDA-NEXT: [[B_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[B_PRIV]],<br>
+ // LAMBDA-NEXT: [[DEC:%.+]] = add nsw i{{[0-9]+}} [[B_VAL]], -1<br>
+ // LAMBDA-NEXT: store i{{[0-9]+}} [[DEC]], i{{[0-9]+}}* [[B_PRIV]],<br>
+ // LAMBDA-NEXT: [[C_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFC]],<br>
+ // LAMBDA-NEXT: [[C_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[C_PRIV]],<br>
+ // LAMBDA-NEXT: [[DIV:%.+]] = sdiv i{{[0-9]+}} [[C_VAL]], 1<br>
+ // LAMBDA-NEXT: store i{{[0-9]+}} [[DIV]], i{{[0-9]+}}* [[C_PRIV]],<br>
+ // LAMBDA-NEXT: ret void<br>
+<br>
// LAMBDA: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias %{{.+}}, i32* noalias %{{.+}})<br>
// LAMBDA: [[G_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}},<br>
// LAMBDA: [[SIVAR_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}},<br>
@@ -80,6 +170,7 @@ int main() {<br>
#elif defined(BLOCKS)<br>
// BLOCKS: [[G:@.+]] = global i{{[0-9]+}} 1212,<br>
// BLOCKS-LABEL: @main<br>
+ // BLOCKS: call<br>
// BLOCKS: call{{.*}} void {{%.+}}(i8<br>
^{<br>
// BLOCKS: define{{.*}} internal{{.*}} void {{.+}}(i8*<br>
@@ -116,6 +207,35 @@ int main() {<br>
}<br>
}();<br>
return 0;<br>
+// BLOCKS: define {{.+}} @{{.+}}([[SS_TY]]* %<br>
+// BLOCKS: store i{{[0-9]+}} 0, i{{[0-9]+}}* %<br>
+// BLOCKS: store i8<br>
+// BLOCKS: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*)* [[SS_MICROTASK:@.+]] to void<br>
+// BLOCKS: ret<br>
+<br>
+// BLOCKS: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}})<br>
+// BLOCKS-NOT: getelementptr {{.*}}[[SS_TY]], [[SS_TY]]* %<br>
+// BLOCKS: call{{.*}} void<br>
+// BLOCKS: ret void<br>
+<br>
+// BLOCKS: define internal void @{{.+}}(i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}})<br>
+// BLOCKS: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},<br>
+// BLOCKS: [[B_PRIV:%.+]] = alloca i{{[0-9]+}},<br>
+// BLOCKS: [[C_PRIV:%.+]] = alloca i{{[0-9]+}},<br>
+// BLOCKS: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REFA:%.+]],<br>
+// BLOCKS: store i{{[0-9]+}}* [[C_PRIV]], i{{[0-9]+}}** [[REFC:%.+]],<br>
+// BLOCKS-NEXT: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFA]],<br>
+// BLOCKS-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],<br>
+// BLOCKS-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1<br>
+// BLOCKS-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],<br>
+// BLOCKS-NEXT: [[B_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[B_PRIV]],<br>
+// BLOCKS-NEXT: [[DEC:%.+]] = add nsw i{{[0-9]+}} [[B_VAL]], -1<br>
+// BLOCKS-NEXT: store i{{[0-9]+}} [[DEC]], i{{[0-9]+}}* [[B_PRIV]],<br>
+// BLOCKS-NEXT: [[C_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFC]],<br>
+// BLOCKS-NEXT: [[C_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[C_PRIV]],<br>
+// BLOCKS-NEXT: [[DIV:%.+]] = sdiv i{{[0-9]+}} [[C_VAL]], 1<br>
+// BLOCKS-NEXT: store i{{[0-9]+}} [[DIV]], i{{[0-9]+}}* [[C_PRIV]],<br>
+// BLOCKS-NEXT: ret void<br>
#else<br>
S<float> test;<br>
int t_var = 0;<br>
@@ -166,6 +286,31 @@ int main() {<br>
// CHECK: call void [[S_INT_TY_DESTR:@.+]]([[S_INT_TY]]*<br>
// CHECK: ret<br>
//<br>
+// CHECK: define {{.+}} @{{.+}}([[SS_TY]]* %<br>
+// CHECK: store i{{[0-9]+}} 0, i{{[0-9]+}}* %<br>
+// CHECK: store i8<br>
+// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SS_TY]]*)* [[SS_MICROTASK:@.+]] to void<br>
+// CHECK: ret<br>
+<br>
+// CHECK: define internal void [[SS_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SS_TY]]* %{{.+}})<br>
+// CHECK: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},<br>
+// CHECK: [[B_PRIV:%.+]] = alloca i{{[0-9]+}},<br>
+// CHECK: [[C_PRIV:%.+]] = alloca i{{[0-9]+}},<br>
+// CHECK: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REFA:%.+]],<br>
+// CHECK: store i{{[0-9]+}}* [[C_PRIV]], i{{[0-9]+}}** [[REFC:%.+]],<br>
+// CHECK-NEXT: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFA]],<br>
+// CHECK-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],<br>
+// CHECK-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1<br>
+// CHECK-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],<br>
+// CHECK-NEXT: [[B_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[B_PRIV]],<br>
+// CHECK-NEXT: [[DEC:%.+]] = add nsw i{{[0-9]+}} [[B_VAL]], -1<br>
+// CHECK-NEXT: store i{{[0-9]+}} [[DEC]], i{{[0-9]+}}* [[B_PRIV]],<br>
+// CHECK-NEXT: [[C_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REFC]],<br>
+// CHECK-NEXT: [[C_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[C_PRIV]],<br>
+// CHECK-NEXT: [[DIV:%.+]] = sdiv i{{[0-9]+}} [[C_VAL]], 1<br>
+// CHECK-NEXT: store i{{[0-9]+}} [[DIV]], i{{[0-9]+}}* [[C_PRIV]],<br>
+// CHECK-NEXT: ret void<br>
+<br>
// CHECK: define internal void [[TMAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}})<br>
// CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}}, align 128<br>
// CHECK: [[VEC_PRIV:%.+]] = alloca [2 x i{{[0-9]+}}], align 128<br>
@@ -184,5 +329,20 @@ int main() {<br>
// CHECK-DAG: call void [[S_INT_TY_DESTR]]([[S_INT_TY]]* [[VAR_PRIV]])<br>
// CHECK-DAG: call void [[S_INT_TY_DESTR]]([[S_INT_TY]]*<br>
// CHECK: ret void<br>
+<br>
+// CHECK: define {{.+}} @{{.+}}([[SST_TY]]* %<br>
+// CHECK: store i{{[0-9]+}} 0, i{{[0-9]+}}* %<br>
+// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[SST_TY]]*)* [[SST_MICROTASK:@.+]] to void<br>
+// CHECK: ret<br>
+<br>
+// CHECK: define internal void [[SST_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}}, [[SST_TY]]* %{{.+}})<br>
+// CHECK: [[A_PRIV:%.+]] = alloca i{{[0-9]+}},<br>
+// CHECK: store i{{[0-9]+}}* [[A_PRIV]], i{{[0-9]+}}** [[REF:%.+]],<br>
+// CHECK-NEXT: [[A_PRIV:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[REF]],<br>
+// CHECK-NEXT: [[A_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[A_PRIV]],<br>
+// CHECK-NEXT: [[INC:%.+]] = add nsw i{{[0-9]+}} [[A_VAL]], 1<br>
+// CHECK-NEXT: store i{{[0-9]+}} [[INC]], i{{[0-9]+}}* [[A_PRIV]],<br>
+// CHECK-NEXT: ret void<br>
+<br>
#endif<br>
<br>
<br>
Modified: cfe/trunk/tools/libclang/CIndex.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=260077&r1=260076&r2=260077&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=260077&r1=260076&r2=260077&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/tools/libclang/CIndex.cpp (original)<br>
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Feb 8 03:29:13 2016<br>
@@ -5669,6 +5669,7 @@ CXCursor clang_getCursorDefinition(CXCur<br>
case Decl::StaticAssert:<br>
case Decl::Block:<br>
case Decl::Captured:<br>
+ case Decl::OMPCapturedField:<br>
case Decl::Label: // FIXME: Is this right??<br>
case Decl::ClassScopeFunctionSpecialization:<br>
case Decl::Import:<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>