diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2015-08-18 06:47:21 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2015-08-18 06:47:21 +0000 |
commit | bd9fec1eaacb7f0769017aef8f6f6453dd160b7f (patch) | |
tree | 835f6e7bf3f7d0d34ef6536db38a40fc442868a7 /clang/lib/CodeGen | |
parent | 3c32c83daa5e7ceda3f5cb7cd3bf4059c197a202 (diff) | |
download | bcm5719-llvm-bd9fec1eaacb7f0769017aef8f6f6453dd160b7f.tar.gz bcm5719-llvm-bd9fec1eaacb7f0769017aef8f6f6453dd160b7f.zip |
[OPENMP 4.1] Allow variables with reference types in private clauses.
OpenMP 4.1 allows to use variables with reference types in all private clauses (private, firstprivate, lastprivate, linear etc.). Patch allows to use such variables and fixes codegen for linear variables with reference types.
llvm-svn: 245268
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 1f1000beb44..ecf95c6d8ca 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -721,17 +721,20 @@ emitPrivateLinearVars(CodeGenFunction &CGF, const OMPExecutableDirective &D, CodeGenFunction::OMPPrivateScope &PrivateScope) { for (auto &&I = D.getClausesOfKind(OMPC_linear); I; ++I) { auto *C = cast<OMPLinearClause>(*I); + auto CurPrivate = C->privates().begin(); for (auto *E : C->varlists()) { - auto VD = cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl()); - bool IsRegistered = PrivateScope.addPrivate(VD, [&]()->llvm::Value * { - // Emit var without initialization. - auto VarEmission = CGF.EmitAutoVarAlloca(*VD); - CGF.EmitAutoVarCleanups(VarEmission); - return VarEmission.getAllocatedAddress(); + auto *VD = cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl()); + auto *PrivateVD = + cast<VarDecl>(cast<DeclRefExpr>(*CurPrivate)->getDecl()); + bool IsRegistered = PrivateScope.addPrivate(VD, [&]() -> llvm::Value * { + // Emit private VarDecl with copy init. + CGF.EmitVarDecl(*PrivateVD); + return CGF.GetAddrOfLocalVar(PrivateVD); }); assert(IsRegistered && "linear var already registered as private"); // Silence the warning about unused variable. (void)IsRegistered; + ++CurPrivate; } } } |