From 87ffb49ebb7577d3943b9bb44203369d2385a8ed Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Thu, 7 Jul 2016 11:04:06 +0000 Subject: [PATCH] [OPENMP] Do not create helper expressions in dependent contexts, NFC. OpenMP relies on some helper expressions generated during semantic analysis. But they are required only for codegen and not required in dependent contexts. Patch removes generation of some of helper expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274745 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaOpenMP.cpp | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index 4b68eeb8f1..59c2f8bfc0 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -4380,6 +4380,8 @@ bool OpenMPIterationSpaceChecker::CheckInc(Expr *S) { static ExprResult tryBuildCapture(Sema &SemaRef, Expr *Capture, llvm::MapVector &Captures) { + if (SemaRef.CurContext->isDependentContext()) + return ExprResult(Capture); if (Capture->isEvaluatable(SemaRef.Context, Expr::SE_AllowSideEffects)) return SemaRef.PerformImplicitConversion( Capture->IgnoreImpCasts(), Capture->getType(), Sema::AA_Converting, @@ -8224,10 +8226,12 @@ OMPClause *Sema::ActOnOpenMPPrivateClause(ArrayRef VarList, *this, VDPrivate, RefExpr->getType().getUnqualifiedType(), ELoc); DeclRefExpr *Ref = nullptr; - if (!VD) + if (!VD && !CurContext->isDependentContext()) Ref = buildCapture(*this, D, SimpleRefExpr, /*WithInit=*/false); DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_private, Ref); - Vars.push_back(VD ? RefExpr->IgnoreParens() : Ref); + Vars.push_back((VD || CurContext->isDependentContext()) + ? RefExpr->IgnoreParens() + : Ref); PrivateCopies.push_back(VDPrivateRefExpr); } @@ -8522,7 +8526,7 @@ OMPClause *Sema::ActOnOpenMPFirstprivateClause(ArrayRef VarList, *this, VDPrivate, RefExpr->getType().getUnqualifiedType(), RefExpr->getExprLoc()); DeclRefExpr *Ref = nullptr; - if (!VD) { + if (!VD && !CurContext->isDependentContext()) { if (TopDVar.CKind == OMPC_lastprivate) Ref = TopDVar.PrivateCopy; else { @@ -8532,7 +8536,9 @@ OMPClause *Sema::ActOnOpenMPFirstprivateClause(ArrayRef VarList, } } DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_firstprivate, Ref); - Vars.push_back(VD ? RefExpr->IgnoreParens() : Ref); + Vars.push_back((VD || CurContext->isDependentContext()) + ? RefExpr->IgnoreParens() + : Ref); PrivateCopies.push_back(VDPrivateRefExpr); Inits.push_back(VDInitRefExpr); } @@ -8661,7 +8667,7 @@ OMPClause *Sema::ActOnOpenMPLastprivateClause(ArrayRef VarList, continue; DeclRefExpr *Ref = nullptr; - if (!VD) { + if (!VD && !CurContext->isDependentContext()) { if (TopDVar.CKind == OMPC_firstprivate) Ref = TopDVar.PrivateCopy; else { @@ -8685,7 +8691,9 @@ OMPClause *Sema::ActOnOpenMPLastprivateClause(ArrayRef VarList, } } DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_lastprivate, Ref); - Vars.push_back(VD ? RefExpr->IgnoreParens() : Ref); + Vars.push_back((VD || CurContext->isDependentContext()) + ? RefExpr->IgnoreParens() + : Ref); SrcExprs.push_back(PseudoSrcExpr); DstExprs.push_back(PseudoDstExpr); AssignmentOps.push_back(AssignmentOp.get()); @@ -8737,10 +8745,12 @@ OMPClause *Sema::ActOnOpenMPSharedClause(ArrayRef VarList, } DeclRefExpr *Ref = nullptr; - if (!VD && IsOpenMPCapturedDecl(D)) + if (!VD && IsOpenMPCapturedDecl(D) && !CurContext->isDependentContext()) Ref = buildCapture(*this, D, SimpleRefExpr, /*WithInit=*/true); DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_shared, Ref); - Vars.push_back((VD || !Ref) ? RefExpr->IgnoreParens() : Ref); + Vars.push_back((VD || !Ref || CurContext->isDependentContext()) + ? RefExpr->IgnoreParens() + : Ref); } if (Vars.empty()) @@ -9421,7 +9431,7 @@ OMPClause *Sema::ActOnOpenMPReductionClause( DeclRefExpr *Ref = nullptr; Expr *VarsExpr = RefExpr->IgnoreParens(); - if (!VD) { + if (!VD && !CurContext->isDependentContext()) { if (ASE || OASE) { TransformExprToCaptures RebuildToCapture(*this, D); VarsExpr = @@ -9579,7 +9589,7 @@ OMPClause *Sema::ActOnOpenMPLinearClause( VarDecl *Init = buildVarDecl(*this, ELoc, Type, ".linear.start"); Expr *InitExpr; DeclRefExpr *Ref = nullptr; - if (!VD) { + if (!VD && !CurContext->isDependentContext()) { Ref = buildCapture(*this, D, SimpleRefExpr, /*WithInit=*/false); if (!IsOpenMPCapturedDecl(D)) { ExprCaptures.push_back(Ref->getDecl()); @@ -9606,7 +9616,9 @@ OMPClause *Sema::ActOnOpenMPLinearClause( auto InitRef = buildDeclRefExpr(*this, Init, Type, ELoc); DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_linear, Ref); - Vars.push_back(VD ? RefExpr->IgnoreParens() : Ref); + Vars.push_back((VD || CurContext->isDependentContext()) + ? RefExpr->IgnoreParens() + : Ref); Privates.push_back(PrivateRef); Inits.push_back(InitRef); } -- 2.50.1